select col1,col6
from tab
union all
select col2,col7
from tab
union all
select col3,col8
from tab
union all
select col4,col9
from tab
union all
select col5,col10
from tab
from tab
union all
select col2,col7
from tab
union all
select col3,col8
from tab
union all
select col4,col9
from tab
union all
select col5,col10
from tab
解决方案 »
- 怎么将date型的日期年份加4年,替换掉对应着的另一个date型的字段里?
- SQL Server 2005的configuration tools中的sql server surface area configuration检测不到database engine
- 關于事件探查器(Sql Profiler)的使用
- 新作的网站,大家给点意见吧
- 导入远程SQL的问题
- 请问怎么用SQL语句。来实现找出一个表内相同的项
- 求2条SQL语句
- 急!MSSqL数据导入到access发生类型改变问题。。
- 关于一个SQL问题
- 请介绍写存储过程的好书,需要大量实用例子的
- 一般在MSSQL里,大家在数据设计时候对于货币值用啥样的类型,精度怎么处理?
- 请高手指点,我这样删除主键约束,为啥报错??
create table #
(f1 varchar(100))
insert into #
select '1,2,3,4,5,a,b,c,d,e'
select top 100 id=identity(int,1,1) into #1 from sysobjectsselect
substring(a.f1,b.id,charindex(',',a.f1+',',b.id)-b.id)as name
into #2
from # a ,#1 b
where substring(','+a.f1,b.id,1)=','
select a.name,b.name
from
(select *,col=(select count(1) from #2 where name<a.name and isnumeric(name)=1) from #2 a where isnumeric(name)=1 )a,
(select *,col=(select count(1) from #2 where name<a.name and isnumeric(name)=0) from #2 a where isnumeric(name)=0 )b
where a.col=b.col/*
name name
---------------------------------------------------------------------------------------------------- ----------------------------------------------------------------------------------------------------
1 a
2 b
3 c
4 d
5 e(所影响的行数为 5 行)
*/