自己写的sql排序
create function dbo.Fn_Sort ( @str varchar(1024) )
returns nvarchar(100)
as
begin
declare @tb table(num int)
declare @strtemp varchar(100)
declare @cID varchar(100)
declare @cEidx int
declare @relation_code varchar(1024)
set @relation_code=@str + ','
while charindex(',',@relation_code) > 0
begin
set @cEidx = charindex(',',@relation_code,1)
set @cID = substring(@relation_code,1,@cEidx-1)
set @relation_code=substring(@relation_code,@cEidx+1,len(@relation_code)-@cEidx)
insert into @tb values(@cID)
end
select @strtemp=isnull(@strtemp+',','')+rtrim(num) from @tb order by num return @strtemp
end
select dbo.Fn_Sort('3,2,35,6,4,8')