DECLARE @i INT=0;
DECLARE @j INT;
DECLARE @qnum INT=300; --生成随机数的数量
SET NOCOUNT ON
CREATE TABLE #temp_Table(num INT)
WHILE(@i@qnum)
BEGIN
SELECT @j = cast( floor(rand()*(99999999-10000000)+10000000) as int)
IF(NOT EXISTS(SELECT num FROM #temp_Table WHERE num=@j ))
BEGIN
INSERT #temp_Table (num) VALUES (@j)
SET @i+=1;
END
END
SELECT DISTINCT num FROM #temp_Table
DROP TABLE #temp_Table