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 |
|
pravin14u
Posting Yak Master
246 Posts |
Posted - 2004-07-12 : 06:17:11
|
| Hii tried the rand() function without a seed value.It returned different set of values for different executions.So whats the difference in using a seed value and not using that with the rand() function?thank you |
|
|
derrickleggett
Pointy Haired Yak DBA
4184 Posts |
Posted - 2004-07-12 : 08:33:45
|
| Books Online is your friend. :)RAND Topic last updated -- July 2003Returns a random float value from 0 through 1.SyntaxRAND ( [ seed ] ) ArgumentsseedIs an integer expression (tinyint, smallint, or int) that specifies the seed value. If seed is not specified, Microsoft® SQL Server™ 2000 assigns a seed value at random. For a given seed value, the result returned is always the same.Return TypesfloatRemarksRepetitive calls of RAND() with the same seed value in a single query return the same results. For a connection, if RAND() is called with a specified seed value, all subsequent calls of RAND() produce results based on the seeded RAND() call. For example, the following query always returns the same sequence of numbers.SELECT RAND(100), RAND(), RAND() ExamplesThis example produces four different random numbers generated with the RAND function.DECLARE @counter smallintSET @counter = 1WHILE @counter < 5 BEGIN SELECT RAND() Random_Number SET NOCOUNT ON SET @counter = @counter + 1 SET NOCOUNT OFF ENDGOMeanOldDBAderrickleggett@hotmail.comWhen life gives you a lemon, fire the DBA. |
 |
|
|
|
|
|