如果你能用某一个或几个字段来确定一条记录,则可通过循环来很快的解决! select @lcSerio=1 declare abc Cursor for select 能确定一条记录的字段列表 from tablename open abc fetch next from abc into 与"能确定一条记录的字段列表"对应的变量 while (@@fetch_status=0) begin update tablename set 主键列=@lnSerio where“确定一条记录的字段列表”与“定义的对应变量列表”组成的条件表达式 select @lnSerio=@lnSerio+1
fetch next from abc into 与"能确定一条记录的字段列表"对应的变量 end
close abc deallocate abc
select identity(int, 1,1) as aaid, * into office_a from gmcccard..office
alter table tablename add aaid int identity(1,1) primary key 加一个identity列
select @lcSerio=1
declare abc Cursor for select 能确定一条记录的字段列表
from tablename
open abc fetch next from abc into 与"能确定一条记录的字段列表"对应的变量
while (@@fetch_status=0)
begin
update tablename set 主键列=@lnSerio where“确定一条记录的字段列表”与“定义的对应变量列表”组成的条件表达式
select @lnSerio=@lnSerio+1
fetch next from abc into 与"能确定一条记录的字段列表"对应的变量
end
close abc deallocate abc
add aaid int identity(1,1) primary key
加一个identity列