sql语句中生成0-10随机数
DECLARE @i int=0;
DECLARE @j decimal(9,2);
DECLARE @qnum INT=1000;
SET NOCOUNT ON
CREATE TABLE #temp_Table(num decimal(9,2))
WHILE(@i<@qnum)
BEGIN
SELECT @j = convert(decimal(9,2),(RAND()*10))
--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
SELECT num FROM #temp_Table
DROP TABLE #temp_Table