Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 

Get your favorite SSC scripts directly in SSMS with the free SQL Scripts addin. Search for scripts directly from SSMS, and instantly access any saved scripts in your SSC briefcase from the favorites tab.
Download now (direct download link)

Non repetable random number generation script

By ravi lobo,

Some time back i had the requirement for a SP which will give non repeatable random numbers with in a range. Following SP accepts a range and gives the random numbers. Once the numbers are exhausetd NULL, will be the out put. In this case user can restart the random number generation by passing 1 as the third parameter. EXECUTION --------- DECLARE @from int ,@to int ,@restart int -- (0 or 1) SELECT @from=10, @to=15 EXECUTE non_repeat_rand @from,@to -- or EXECUTE non_repeat_rand 10,15,1

Total article views: 216 | Views in the last 30 days: 2
 
Related Articles
ARTICLE

Finding Unique Non-Repeating Random Numbers

Learn three methods of creating random numbers that do not repeat in this article from Brandie Tarvi...

FORUM

Random number generator

Random numbers

FORUM

How to Get Random Numbers

How to Get Random Numbers

ARTICLE

Generating Non-uniform Random Numbers with SQL

Some FUNCTIONs to help generate non-uniform random numbers from uniform random numbers including Nor...

BLOG

T-SQL Random Numbers using RAND() for Test Data

T-SQL Random Numbers using RAND() SQL Server includes the T-SQL RAND() function to create a rando...

Tags
miscellaneous    
 
Contribute