Accessing unique identifier

Posted on 2005-05-10
Last Modified: 2010-03-19
I added a unique ID column after I already created a table, like

ALTER TABLE maintable
ADD UniqueID uniqueidentifier NOT Null DEFAULT NEWID()

The values appear to be encoded values, i.e.



I need a row id so that I can reference each data item with repeater tag in How do I access these values??
Question by:dprasad
    LVL 68

    Accepted Solution

    If all you need is a value unique *within that table* (not across tables), you can change to an IDENTITY column instead of a uniqueidentifier:

    ALTER TABLE maintable
    ADD ident INT IDENTITY(1,1)

    Which will assign each row an ever-growing sequential number; first row is 1, second is 2, etc..  There could, and almost certainly will be, gaps in the identity numbers, however.

    Author Comment

    great that works, well so far so good as far as gaps, thanks a lot


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    What Should I Do With This Threat Intelligence?

    Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

    Suggested Solutions

    Title # Comments Views Activity
    SQL Searching 3 35
    Set the max value for a column 7 21
    Delete from table 6 26
    The steps for moving the system databases to a new location are documented in the following technical article: However sometimes after the moving process is finished, though SQL i…
    Introduction In my previous article ( I showed you how the XML Source component can be used to load XML files into a SQL Server database, us…
    Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.
    Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.

    761 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    10 Experts available now in Live!

    Get 1:1 Help Now