Quickly Generate Random number by TSQL with 99.9% Uniqueness Guarntee

  • Comments posted to this topic are about the item Quickly Generate Random number by TSQL with 99.9% Uniqueness Guarntee

  • I was not able to run the script. I pasted use temdb as first line. I am using SQL Server Management studio 2008 as client and SQL server 2005 as server.

    following are the errors that i was getting

    Msg 102, Level 15, State 1, Line 10

    Incorrect syntax near '?'.

    Msg 102, Level 15, State 1, Line 11

    Incorrect syntax near '?'.

    Msg 102, Level 15, State 1, Line 13

    Incorrect syntax near ')'.

    Msg 102, Level 15, State 1, Line 17

    Incorrect syntax near '?'.

    Msg 102, Level 15, State 1, Line 22

    Incorrect syntax near '?'.

    Msg 208, Level 16, State 1, Line 5

    Invalid object name 'tblTest'.

    Msg 3701, Level 11, State 5, Line 3

    Cannot drop the table 'tblTest', because it does not exist or you do not have permission.

  • Very cool. My results were 1080 duplicate numbers, each appearing twice. No number returned 3 times. Out of 3 million, that's 99.96% unique. 🙂

  • I had the same issue.

    I copied the code into TextPad and got rid of the leading "spaces" within the CTEs. For example, there are 4 characters at the beginning of the line "Select 1 as n" that aren't really spaces.

    :w00t:

  • I checked the issue. This is due to some unprintable characters inserted by HTML. To solve this issue, copy the code in notepad first and you wil see the box for unprintable chracters. Just replace all occurances of that character with a space. After this, Copy the code from notepad and paste it in your Query Analyzer window. It will work like a charm.

  • Thanks for the script.

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

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