Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
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: 214 | Views in the last 30 days: 2
Related Articles

Finding Unique Non-Repeating Random Numbers

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


Random number generator

Random numbers


How to Get Random Numbers

How to Get Random Numbers


Generating Non-uniform Random Numbers with SQL

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


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...


Join the most active online SQL Server Community

SQL knowledge, delivered daily, free:

Email address:  

You make SSC a better place

As a member of SQLServerCentral, you get free access to loads of fresh content: thousands of articles and SQL scripts, a library of free eBooks, a weekly database news roundup, a great Q & A platform… And it’s our huge, buzzing community of SQL Server Professionals that makes it such a success.

Join us!

Steve Jones

Already a member? Jump in:

Email address:   Password:   Remember me: Forgotten your password?
Steve Jones