DECLARE @nMinimumCount INT= 1
DECLARE @nMaximumCount INT= 100
SELECT abs(CHECKSUM(NEWID()))%(@nMaximumCount+ 1-@nMinimumCount)+@nMinimumCount

@nMinimumCount ,@nMaximumCount为指定获取随机数的最小和最大范围

04-28 12:04