select 的时候如何生成自动增长列``?? 比如: select myID=在这怎么写能生成自动ID ,* from a
------解决方案-------------------- select myID=Row_Number() over(order by myID) from Table 不知道是不是你要的结果~
------解决方案--------------------
SELECT myID= (SELECT COUNT(编号) FROM 表1 AS T1 WHERE T1.编号<= T2.编号), 编号,名称 FROM 表2 AS T2ORDER BY 1; GO
------解决方案--------------------
SQL code
use pubs
go
select ID=identity(int, 1, 1), * into #t from titles
select * from #t
drop table #t
------解决方案-------------------- 不懂
------解决方案-------------------- identity(int,1,1)+临时表
------解决方案-------------------- @@identity(int, 1, 1),
------解决方案-------------------- select myID=(select count(列名) from 表名 as a where a.列名<b.列名),列名 from 表名 as b
------解决方案-------------------- select myID=identity(int, 1, 1), c.* into #t from ( select 姓名=aname,支出钱=amoney,收入钱='',时间=atime from a union all select bname,支出钱='',收入钱=bmoney,时间=btime from b order by 时间 ) c select * from #t drop table #t