我想我已经破解了一种生成随机数的方法。但是 SQL Server 中有效循环这个的最佳方法是什么?我有以下 SQL:
DECLARE @Random1 INT;
DECLARE @Random2 INT;
DECLARE @Random3 INT;
DECLARE @Random4 INT;
DECLARE @Random5 INT;
DECLARE @Random6 INT;
DECLARE @Upper INT;
DECLARE @Lower INT;
---- This will create a random number between 1 and 49
SET @Lower = 1 ---- The lowest random number
SET @Upper = 49 ---- The highest random number
SELECT @Random1 = ROUND(((@Upper - @Lower -1) * RAND() + @Lower), 0)
SELECT @Random2 = ROUND(((@Upper - @Lower -1) * RAND() + @Lower), 0)
SELECT @Random3 = ROUND(((@Upper - @Lower -1) * RAND() + @Lower), 0)
SELECT @Random4 = ROUND(((@Upper - @Lower -1) * RAND() + @Lower), 0)
SELECT @Random5 = ROUND(((@Upper - @Lower -1) * RAND() + @Lower), 0)
SELECT @Random6 = ROUND(((@Upper - @Lower -1) * RAND() + @Lower), 0)
--SELECT @Random;
INSERT INTO [lotto].[dbo].[CustomerSelections]
([draw_date]
,[val1]
,[val2]
,[val3]
,[val4]
,[val5]
,[val6])
VALUES
(
'2013-07-05'
,@Random1
,@Random2
,@Random3
,@Random4
,@Random5
,@Random6
)
让 SQL Server 运行此 SQL 100,000 次的最佳方法是什么?