sql语句序号生成

来源:互联网 发布:黑河龙江网络 编辑:程序博客网 时间:2024/03/29 20:11

select IDENTITY(int,1,1) ID,*  into #temp from yourtable
select * from #temp
Drop table #temp

 

如果有主键则可以这样:
SELECT (SELECT COUNT(主键)
          FROM tftable  b
          WHERE b.主键<= a.主键) AS id, indate,outdate
FROM tftable  a
ORDER BY 主键

原创粉丝点击