提醒: 我是要一次插入多行 用方法 update tablename set r = ROUND(255*RAND(),0), g = ROUND(255*RAND(),0), b = ROUND(255*RAND(),0), 只能插入一组随机值 即如果取到的随机组是(222,58,47)的话 所有的记录都是 item R G B a 222,58,47 a 222,58,47 a 222,58,47 a 222,58,47 a 222,58,47而不是我想要的多组随机值!!!
用游标吧: declare a cursor for select r,g,b from tablename open a fetch next from a while (@@fetch_status<>-1) begin update tablename set r = ROUND(255*RAND(),0), g = ROUND(255*RAND(),0), b = ROUND(255*RAND(),0) at current of a fetch next from a end close a deallocate a
我是要一次插入多行
用方法
update tablename set
r = ROUND(255*RAND(),0),
g = ROUND(255*RAND(),0),
b = ROUND(255*RAND(),0),
只能插入一组随机值
即如果取到的随机组是(222,58,47)的话
所有的记录都是
item R G B
a 222,58,47
a 222,58,47
a 222,58,47
a 222,58,47
a 222,58,47而不是我想要的多组随机值!!!
declare a cursor for
select r,g,b from tablename
open a
fetch next from a
while (@@fetch_status<>-1)
begin
update tablename
set r = ROUND(255*RAND(),0),
g = ROUND(255*RAND(),0),
b = ROUND(255*RAND(),0)
at current of a
fetch next from a
end
close a
deallocate a