if not object_id('Tempdb..#T') is null
drop table #T
Go
Create table #T([usercode] nvarchar(10),[username] varchar(10),[sex] char(10),[age] int)
Insert #T
select 'aa','张三','男',10 union all
select 'bb','李四','男',12 union all
select 'cc','小红','女',12 select * from #T
得到结果:
usercode username sex age
---------- ---------- ---------- -----------
aa 张三 男 10
bb 李四 男 12
cc 小红 女 12我希望用最快方法得到:自动增加流水号,系统有这样的函数吗? ID usercode username sex age
---------- ---------- ---------- -----------
1 aa 张三 男 10
2 bb 李四 男 12
3 cc 小红 女 12不希望通过表结构设置属性IDENTITY(1,1) 达成!
drop table #T
Go
Create table #T([usercode] nvarchar(10),[username] varchar(10),[sex] char(10),[age] int)
Insert #T
select 'aa','张三','男',10 union all
select 'bb','李四','男',12 union all
select 'cc','小红','女',12 select * from #T
得到结果:
usercode username sex age
---------- ---------- ---------- -----------
aa 张三 男 10
bb 李四 男 12
cc 小红 女 12我希望用最快方法得到:自动增加流水号,系统有这样的函数吗? ID usercode username sex age
---------- ---------- ---------- -----------
1 aa 张三 男 10
2 bb 李四 男 12
3 cc 小红 女 12不希望通过表结构设置属性IDENTITY(1,1) 达成!
row_number()