CodePaste Logo
New Snippet New Snippet Recent Snippets Recent Snippets My Snippets My Snippets Web Code Search Snippets Search
Sign inor Register
Language: SQL

TSQL Random Number within Range

372 Views
Copy Code Show/Hide Line Numbers
   1:  DECLARE @RandomNumber float
   2:  DECLARE @RandomInteger int
   3:  DECLARE @MaxValue int
   4:  DECLARE @MinValue int
   5:   
   6:  SET @MaxValue = 4
   7:  SET @MinValue = 2
   8:   
   9:  SELECT @RandomNumber = RAND()
  10:   
  11:  SELECT @RandomInteger = ((@MaxValue + 1) - @MinValue) * @RandomNumber + @MinValue
  12:   
  13:  SELECT @RandomNumber as RandomNumber, @RandomInteger as RandomInteger
by Jerry Nixon
  April 12, 2010 @ 9:37am
Tags:
Description:
http://www.brettb.com/SQL_Help_Random_Numbers.asp

Add a comment


Report Abuse
brought to you by:
West Wind Techologies



If you find this site useful and use it frequently please consider making a donation to support this free service.
Donate