转一篇关于SQL语句的书写的

如一串数字“3,43,23,64,234,76,5,9,14,27”进行排序输入到空表A中。
要求在表A中的排列方式如下:
num
3
5
9
14
23
27
43
64
76
234
******************************************************************************
create
proc wsp
@sql varchar(1000)
as
create table #temp(num int)
set @sql='insert into #temp select '+replace(@sql,',',' d union all select ')
exec(@sql)
insert into a select * from #temp order by num

然后调用:
exec wsp'3,43,23,64,234,76,23,5,9,14,27'
posted @ 2007-12-13 16:44  灯火阑珊²ºº7  阅读(329)  评论(0编辑  收藏  举报