Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Rand function
Message
 
 
To
08/05/2002 10:48:39
Dave Sonier
Technologies Nter inc.
Gatineau, Quebec, Canada
General information
Forum:
Microsoft SQL Server
Category:
Stored procedures, Triggers, UDFs
Title:
Miscellaneous
Thread ID:
00653746
Message ID:
00654010
Views:
17
>I ran your sample and i got this message:
>
>Server: Msg 137, Level 15, State 2, Line 4
>Must declare the variable '@Rand'.

Depending how random you want your random numbers to be, change it to
SELECT CAST((@RandMax - @RandMin) * Rand() + @RandMin AS int)
-- or
DECLARE @Rand real
SET @Rand = RAND( (DATEPART(mm, GETDATE()) * 100000 ) +
   (DATEPART(ss, GETDATE()) * 1000 ) +
    DATEPART(ms, GETDATE()) )
SELECT CAST((@RandMax - @RandMin) * @Rand + @RandMin AS int)
--sb--
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform