日期:2014-05-18  浏览次数:20499 次

求拆列?
spid F99 F37 F87 F64 F54 F90 F16 F71 F17 F05 F44 F78 F11 F15 F14 F57 F28 F98 F97 F69 F35
SPH00031148 2 5 5 2 2 5 2 2 2 2 2 2 3 2 10 2 2 2 2 2 2
SPH00031183 2 5 5 2 2 5 2 2 2 2 2 2 3 2 10 2 2 2 2 2 2
SPH00031169 5 10 5 5 5 5 3 5 5 3 5 5 5 3 10 2 5 2 2 3 5
SPH00031179 2 5 2 2 2 2 2 2 2 2 2 2 2 2 7 2 2 2 2 2 2
SPH00031180 3 10 5 2 2 5 2 5 2 2 2 5 5 3 10 5 2 2 2 2 4
SPH00031172 2 5 5 2 2 5 2 2 2 2 2 2 3 2 10 2 2 2 2 2 2
SPH00031155 2 5 5 2 2 5 2 2 2 2 2 2 3 2 10 2 2 2 2 2 2
SPH00031170 2 5 5 2 2 5 2 2 2 2 2 2 3 2 10 2 2 2 2 2 2
SPH00031165 5 10 10 3 3 5 3 5 5 3 3 5 5 3 10 5 5 3 3 3 3
SPH00031164 2 5 5 2 2 5 2 2 2 2 2 2 3 2 10 2 2 2 2 2 2
SPH00031163 2 5 5 2 2 5 2 2 2 2 2 2 3 2 10 2 2 2 2 2 2
SPH00031166 5 10 10 3 3 5 3 5 5 3 3 5 5 3 10 5 5 3 3 3 3
SPH00031167 10 20 10 10 10 10 10 10 10 5 5 10 10 10 20 10 10 5 5 5 5
SPH00031145 2 5 2 2 2 2 2 2 0 0 0 2 2 2 5 2 2 0 2 2 2
SPH00031146 1 2 1 0 0 1 1 1 0 0 0 0 1 0 2 0 0 0 0 0 0
SPH00031153 3 10 5 2 2 5 2 5 2 2 2 5 5 3 10 5 2 2 2 2 4
SPH00031154 5 10 10 3 3 5 3 5 5 3 3 5 5 3 10 5 5 3 3 3 3
SPH00031177 2 5 2 2 2 2 2 2 2 2 2 2 2 2 7 2 2 2 2 2 2
SPH00031178 2 5 5 2 2 5 2 2 2 2 2 2 3 2 10 2 2 2 2 2 2
SPH00005106 2 5 2 2 2 2 2 2 2 2 2 2 2 2 7 2 2 2 2 2 2
SPH00005107 5 10 10 3 3 5 3 5 5 3 3 5 5 3 10 5 5 3 3 3 3
SPH00031147 2 5 2 0 0 2 0 1 0 0 0 2 2 2 5 2 2 0 0 0 1
SPH00031149 3 10 5 2 2 5 2 5 2 2 2 5 5 3 10 5 2 2 2 2 4
SPH00031150 3 10 5 2 2 5 2 5 2 2 2 5 5 3 10 5 2 2 2 2 4
SPH00031151 2 5 5 2 2 5 2 2 2 2 2 2 3 2 10 2 2 2 2 2 2
SPH00031152 5 10 10 3 3 5 3 5 5 3 3 5 5 3 10 5 5 3 3 3 3
SPH00030845 2 5 5 2 2 5 2 2 2 2 2 2 3 2 10 2 2 2 2 2 2
SPH00031160 3 10 5 2 2 5 2 5 2 2 2 5 5 3 10 5 2 2 2 2 4
SPH00031159 3 10 5 2 2 5 2 5 2 2 2 5 5 3 10 5 2 2 2 2 4
SPH00031182 2 5 5 2 2 5 2 2 2 2 2 2 3 2 10 2 2 2 2 2 2
SPH00031157 2 5 5 2 2 5 2 2 2 2 2 2 3 2 10 2 2 2 2 2 2
SPH00031158 5 10 10 3 3 5 3 5 5 3 3 5 5 3 10 5 5 3 3 3 3
SPH00031156 10 20 10 5 5 5 5 5 5 5 5 5 5 10 20 5 5 5 5 5 5
SPH00031162 5 10 10 3 3 5 3 5 5 3 3 5 5 3 10 5 5 3 3 3 3
SPH00031171 5 10 10 3 3 5 3 5 10 3 3 10 5 3 18 5 5 3 3 3 5
SPH00031181 2 5 2 0 0 0 0 2 2 0 0 2 0 0 5 0 0 0 0 0 0
SPH00031175 2 5 2 2 2 2 2 2 2 2 2 2 2 2 7 2 2 2 2 2 2
SPH00031176 3 10 5 2 2 5 2 5 2 2 2 5 5 3 10 5 2 2 2 2 4
SPH00031186 5 10 10 3 3 5 3 5 5 3 3 5 5 3 10 5 5 3 3 3 3
SPH00031187 5 10 10 3 3 5 3 5 5 3 3 5 5 3 10 5 5 3 3 3 3
SPH00031188 5 10 10 3 3 5 3 5 5 3 3 5 5 3 10 5 5 3 3 3 3
SPH00031189 5 10 10 3 3 5 3 5 5 3 3 5 5 3 10 5 5 3 3 3 3
SPH00031190 5 10 5 3 3 5 3 5 3 3 3 3 5 3 10 5 3 3 3 3 4
SPH00031191 5 10 10 3 3 5 3 5 5 3 3 5 5 3 10 5 5 3 3 3 3

------解决方案--------------------
SQL code
select 'F99',spid,F99 from tb
uion all
select 'F37',spid,F37 from tb 
uion all
select 'F87',spid,F87 from tb  
uion all
select 'F64',spid,F64 from tb  
uion all
select 'F54',spid,F54 from tb  
uion all
select 'F90',spid,F90 from tb  
uion all
select 'F16',spid,F16 from tb  
uion all
select 'F71',spid,F71 from tb  
uion all
select 'F17',spid,F17 from tb  
uion all
select 'F05',spid,F05 from tb  
uion all
select 'F44',spid,F44 from tb  
uion all
select 'F78',spid,F78 from tb  
uion all
select 'F11',spid,F11 from tb  
uion all
select 'F15',spid,F15 from tb  
uion all
select 'F14',spid,F14 from tb  
uion all
select 'F57',spid,F57 from tb  
uion all
select 'F28',spid,F28 from tb  
uion all
select 'F98',spid,F98 from tb  
uion all
select 'F97',spid,F97 from tb  
uion all
select 'F69',spid,F69 from tb  
uion all
select 'F35',spid,F35 from tb

------解决方案--------------------
SQL code

--假设表名:sptable

declare @sql varchar(8000) set @sql=''
select @sql=
@sql+' select '''+name+''' as col1,spid as col2,'+
name+' as col3 from sptable union all'
from sys