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)

Procedure for Random Numbers

By nagdimunovd,

Here is handy procedure to generate random number.
I find it useful when I generate large amount of test data in a database.
For example if you need to create a Customer Data and what they have purchased in the last month to run perfrmance tests on large amount of data an set up necessary indexes.
You can insert records into customer table and put in a random amount for the purchase price or assign a ID of related item id, if Index in the related table is sequential you can put in min(id) and Max(id) get a random item id and Assign it to your customer record.
Also you can use it when ever you need to generate a random number between 2 numbers.

Good Luck
Dan

Total article views: 576 | Views in the last 30 days: 1
 
Related Articles
FORUM

Random number generator

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

FORUM

How to Get Random Numbers

How to Get Random Numbers

FORUM

Random Phone numbers

Can anyone help me generate a statement that will update a table with random phone numbers with the ...

SCRIPT

Quickly Generate Random number by TSQL with 99.9% Uniqueness Guarntee

Here is the simplest and most efficient technique to guarantee the uniqueness of random numbers.

Tags
miscellaneous    
t-sql    
 
Contribute

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
Editor, SQLServerCentral.com

Already a member? Jump in:

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