will any one help

  • Will any one help with this functionRAND(CHECKSUM(NEWID()). I googled it but i cant find exact solution and explanation.

  • 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

  • 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


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

  • 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

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply