insert into B select Title from A order by newid()
insert B select TITLE from A
补充:B表的AWORDS字段有很多数据,并不是只更新一行 随即更新数据,谢谢
insert into B select Title from A order by id
两个表中都应该有ID字段吧。 利用随机函数 declare @cInt set @cInt=cast( floor(rand()*12) as int) insert B(AWORDS) select TITLE from A where id=@cInt
类似这样的效果update ibpenimg set e=abs(checksum(newid())) % 30 + 70
insert into b(AWORDS) select top 11 TITLE from b
应该是:declare @mobileOsType int; declare @mobileUa varchar(50); declare @id int; declare @num int;set @num=100; while(@num>0) begin select @id=convert(int,rand()*100); select top 1 @mobileUa=title from awords order by newid(); update ibpencompanyname set awords=@mobileUa where id in (select top(@id) id from ibpencompanyname order by newid()); set @num=@num-1; end
学习。建议楼主复杂的SQL去SQL版发,那里也高手如云。很多DBA在那里混的
Insert into B(AWORDS) Select TITLE from A Order by newid()
insert B select TITLE from A
随即更新数据,谢谢
利用随机函数
declare @cInt
set @cInt=cast( floor(rand()*12) as int)
insert B(AWORDS) select TITLE from A where id=@cInt
e=abs(checksum(newid())) % 30 + 70
select top 11 TITLE from b
declare @mobileUa varchar(50);
declare @id int;
declare @num int;set @num=100;
while(@num>0)
begin
select @id=convert(int,rand()*100);
select top 1 @mobileUa=title
from awords order by newid();
update ibpencompanyname
set awords=@mobileUa
where id in (select top(@id) id from ibpencompanyname order by newid());
set @num=@num-1;
end
Select TITLE
from A
Order by newid()