Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
Ken Blum
Constraint Violating Yak Guru
383 Posts |
Posted - 2010-03-24 : 10:43:33
|
I have a table that contains records of water temperatures (numeric data type). I need a script that will return a random number between 7 and 12. How can I achieve that?Select Data_Value, Data_Value + Rand() AS Random_Temp From Water_Temps TIA,Ken |
|
|
Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)
7020 Posts |
Posted - 2010-03-24 : 11:25:03
|
Function F_RANDOM_INTEGER in the script returns a random integer in the range of the input parameters so that the return value is >= @START_INT and <= @END_INT. It is valid for any range of two integer values.Random Integer, Sample, and Datetime Functionshttp://www.sqlteam.com/forums/topic.asp?TOPIC_ID=69499Example: -- Return random integer between 7, 12select [Random Integer] = [dbo].[F_RANDOM_INTEGER](7, 12,newid()) CODO ERGO SUM |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2010-03-24 : 11:33:09
|
| http://sqlblogcasts.com/blogs/madhivanan/archive/2007/10/10/generating-random-numbers-part-ii.aspx------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
Ken Blum
Constraint Violating Yak Guru
383 Posts |
Posted - 2010-03-24 : 11:41:37
|
| Thanks! |
 |
|
|
|
|
|