SQL 生成6位随机数并MD5加密输出
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()*(999999-100000)+100000) 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, dbo.f_MD5(num) FROM #temp_Table
DROP TABLE #temp_Table