SQL 2005 Table Constraint Question

  • Hello All, I have inherited a database in SQL Server 2005 that was created by a contractor that has since left our company. I am trying to figure out how one of the tables in this database is launching a function that resides in the Default Value of Binding property of the modify table area.

    Here is what is happening. There is a table with table values that allow users access to an application. He has written a script that runs when you enter a users details into a row, then right click on the record and execute SQL. This generates an ID that looks like is coming from some sort of algorithm. I am trying to find this algorithm and cannot find it. I notice that when I click on modify table there is a function called NewID() that is in the Default Value or Binding field of the modify table. Can anyone tell me how I can locate this function? or Can someone tell me how to find out what is launched when you right click on a record in a table and select Execute SQL? I'm trying to locate his algorithm.

    Any help would be greatly appreciated.

    Greg

  • NEWID() is a built in function for SQL Server that generates a globally unique identifier value. You can run it within just about any TSQL code. Try:

    SELECT NEWID()

    "The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
    - Theodore Roosevelt

    Author of:
    SQL Server Execution Plans
    SQL Server Query Performance Tuning

  • Thank you so much for imparting your knowledge on me regarding this! I really appreciate it.

    So I can create my id's using this algorithm as well.

    😀

    Thanks,

    Greg

  • You can.

    There are some design issues associated with GUIDs (Globally Unique IDentifiers) that you might want to know about. They're notoriously poor choices for clustered indexes, just as an example.

    "The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
    - Theodore Roosevelt

    Author of:
    SQL Server Execution Plans
    SQL Server Query Performance Tuning

  • Really?!

    Ok, I'll have to take that under advisement when designing an update to the interface.

    Thanks again for you insight.

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

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