Random varchar function exposed?

  • SQL server uses some internal function to make sure object names are unique; ie if you create a foreign key without a name, it makes an object name like this: FK__GMAACCP__ACCOMPR__3553B50D; obviously, there is a function that returns a random number like 3553B50D to be used to make object names unique.

    my question? what is the name of that function? if i know the name, i assume i can use it for my own evil plans for taking over the world and whatnot.

    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!

  • Have no clue. Why do you want to know? If you need a ready-baked randomfunction, why not NEWID() ..?

    /Kenneth

  • actually, I was sitting around playing with a schema generator program, and because i had too much time on my hands, I wondered if whatever SQL uses was exposed or not; there's plenty of random functions out there that I could use of course: here's a 'duplication' of what i figure SQL server is doing: thisd is using a contribution from this site: http://www.sqlservercentral.com/scripts/contributions/1474.asp

     

    select right(

    dbo.ufn_vbintohexstr((RAND () * 100000)  ),6)

    returns :

    9954C1

    E0B252

    6550AC

    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!

  • Yes, looks like it. The suffix generated looks just like a random number in hex.

    Never given a second thought if there was any special function that did that.

    /Kenneth

  • SELECT NEWID()

    Use substring to get a piece if you want.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

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

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