主题:用游标写自动编号内容,搞不定
--把自动编号的设置去掉主键并改为可以为NULL后,其他语句写入了其余记录,最后
--想把1、2、3、4.....的i值通过下面代码写入:
declare @i int,@j int
declare mm cursor for select txnid from mamember
set @i=1
open mm
FETCH NEXT FROM mm into @j
while(@@fetch_status =0 )
begin
print @i
update mamember set txnid=@i where txnid is not null
set @i=@i+1
FETCH NEXT FROM mm into @j
end
close mm
deallocate mm
--搞不定.
--麻烦高手帮忙看一看,是哪里出错了?谢谢!!!
--想把1、2、3、4.....的i值通过下面代码写入:
declare @i int,@j int
declare mm cursor for select txnid from mamember
set @i=1
open mm
FETCH NEXT FROM mm into @j
while(@@fetch_status =0 )
begin
print @i
update mamember set txnid=@i where txnid is not null
set @i=@i+1
FETCH NEXT FROM mm into @j
end
close mm
deallocate mm
--搞不定.
--麻烦高手帮忙看一看,是哪里出错了?谢谢!!!