您的位置:首页 > 其它

如何让所请读取的数据自动产生编号.

2005-10-06 12:59 411 查看
如何让所请读取的数据自动产生编号

方法-:

Select Serial_numbr=( select count(1)+1 from Table_Name

Where number_code<=t.number_code),*

From Table_Name t

(其中的count(1)+1 也可以换成 isnull(sum(1),0)+1

因为sum(1) 会在第一人序号产生为 NULL ,所以用isnull 函数换成 0 )

方法二:(利用#table_temp 临时表来实现)



Select identity(int,1,1) as Serial_Number,* into #table_temp

From Table_Name

Select * from #table_temp

Drop table #table_temp
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐