?
Solved

Accessing unique identifier

Posted on 2005-05-10
2
Medium Priority
?
234 Views
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.

{4C3CBC1C-2455-4FBC-A112-800B9625A1EF}

{E55AFD60-321C-40BA-B260-E1B17B97E5E3}

I need a row id so that I can reference each data item with repeater tag in ASP.net. How do I access these values??
0
Comment
Question by:dprasad
2 Comments
 
LVL 70

Accepted Solution

by:
Scott Pletcher earned 2000 total points
ID: 13971468
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.
0
 

Author Comment

by:dprasad
ID: 13971482
great that works, well so far so good as far as gaps, thanks a lot

D
0

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article shows gives you an overview on SQL Server 2016 row level security. You will also get to know the usages of row-level-security and how it works
Microsoft provides a rich set of technologies for High Availability and Disaster Recovery solutions.
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties
Suggested Courses

593 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