数据表位A_ziliao 有一标志id
首先建立一个过渡表(id,地名)
用游标查询数据表A_ziliao记录id
更改列 sheng 为随机值
declare @fid int,@nn int
declare cursor3 cursor for --定义游标cursor3
select id from A_ziliao --使用游标的对象(跟据需要填入select文)
open cursor3 --打开游标
fetch next from cursor3 into @fid
while @@fetch_status=0 --判断是否成功获取数据
begin
set @nn =4*rand +1'随机id
update A_ziliao set sheng=(select 地名 from 过渡表 where id= @nn )where id=@fid
fetch next from cursor3 into @fid --将游标向下移1行
end
close cursor3 --关闭游标
deallocate cursor3
这个表中有没有其它列作参考?如果还有其它列,表中是否已经有了记录?还是只是要往一个空表中加入上述内容?
直接建个页面搞啊,