July 7, 2011 at 10:45 am
Will any one help with this functionRAND(CHECKSUM(NEWID()). I googled it but i cant find exact solution and explanation.
July 7, 2011 at 10:54 am
This is a method to help get a random result set.
Do you have questions around how to use it or something else?
Jason...AKA CirqueDeSQLeil
_______________________________________________
I have given a name to my pain...MCM SQL Server, MVP
SQL RNNR
Posting Performance Based Questions - Gail Shaw[/url]
Learn Extended Events
July 7, 2011 at 10:55 am
just break it down into it's peices:
SELECT
NEWID(),--returns a varchar-ish something like D93D157E-3749-4A26-8410-859B237CE7FF
CHECKSUM(NEWID()), --returns a bigint like 1339413509 or -1323543251
ABS(CHECKSUM(NEWID())), --makes sure it's positive like 1585842432
RAND(CHECKSUM(NEWID())) --returns a value between 0 and 1 like 0.917917441450155
Lowell
July 7, 2011 at 10:57 am
It's used to get random numbers. It's usually used for data generation for simple tests (like scenarios for blog posts)
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
July 7, 2011 at 11:08 am
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply