读书人

加一列升序列号码,该怎么处理

发布时间: 2012-02-16 21:30:36 作者: rapoo

加一列升序列号码
下面的Alter为什么不行,有其他办法在现有表#Result里加一列升序列号码
select top 100 orderid,cast(null as int) RowId into #result from oeborder
ALTER TABLE #Result ALTER COLUMN RowId int IDENTITY (1,1) null
select * from #result
Drop Table #result

[解决办法]
--try

select top 100 ID=identity(int, 1, 1), orderid,cast(null as int) RowId into #result from oeborder
[解决办法]
select top 100 RowId=identity(int, 1, 1), orderid into #result from oeborder

select * from #result

[解决办法]
ALTER TABLE #Result ADD RowId int IDENTITY (1,1)

这样既可
[解决办法]
把以前的那列删除

读书人网 >SQL Server

热点推荐