SQL语句给某一列自动编号

来源:互联网 发布:淘宝的发货人能不能改 编辑:程序博客网 时间:2024/06/06 19:29

 select * into #temp from(
 select 'a' as coll,' ' id
 union all
 select 'b',' ' id
 union all
 select 'c',' '    id
  union all
 select 'd',' '    id
 )a
 declare @i int=0
 update #temp set id=id+@i,@i=@i+1
 select * from #temp

 drop table #temp



0 0