declare @x table (t varchar(200)) declare @x2 varchar(200) set @x2='03,15,16,08,10' set @x2=@x2+',' while @x2<>'' begin insert into @x (t) values (left(@x2,charindex(',',@x2)-1)) set @x2=right(@x2,len(@x2)-charindex(',',@x2)) end select @x2=@x2+t+',' from @x order by t set @x2=left(@x2,len(@x2)-1) print @x2
直接用: order by 字段 就行了。 如果是('3','15','16','8','10') 就得用:order by cast(字段 as in)
缺了点直接用: order by 字段 就行了。 如果是('3','15','16','8','10') 就得用:order by cast(字段 as int)
declare @x2 varchar(200)
set @x2='03,15,16,08,10'
set @x2=@x2+','
while @x2<>''
begin
insert into @x (t) values (left(@x2,charindex(',',@x2)-1))
set @x2=right(@x2,len(@x2)-charindex(',',@x2))
end
select @x2=@x2+t+',' from @x order by t
set @x2=left(@x2,len(@x2)-1)
print @x2
order by 字段
就行了。
如果是('3','15','16','8','10')
就得用:order by cast(字段 as in)
order by 字段
就行了。
如果是('3','15','16','8','10')
就得用:order by cast(字段 as int)