首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > SQL Server >

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

2012-02-16 
加一列升序列号码下面的Alter为什么不行,有其他办法在现有表#Result里加一列升序列号码selecttop100orderi

加一列升序列号码
下面的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)

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

热点排行