all groups > sql server programming > january 2007 >
You're in the

sql server programming

group:

Applying a unique ID


Applying a unique ID Kayda
1/18/2007 10:36:05 PM
sql server programming:
Hi there:

What is the most efficient way to apply a unique ID to a table through
SQL? I'm working in a SQL Server 2000 DTS package--I have a table that
has unique rows but has a null UniqueID field, and I have another table
that stored the MaximumLast ID from the master table. I am currently
using a WHILE loop but it takes forever.

Thanks!

Kayda
Re: Applying a unique ID Dave Markle
1/19/2007 8:18:34 AM
Kayda -

Please post the definition of your table to the newsgroups (the CREATE
TABLE statements).

-Dave

[quoted text, click to view]
Re: Applying a unique ID Kayda
1/21/2007 9:56:50 PM
OK, here is the code, and some data:

/*Create Maximum ID table for getting IDS*/
CREATE TABLE MaxID (
MaxID int
)

/*Create Fact data table*/
CREATE TABLE FactData (
ID int NULL,
Name varchar(50) NULL
)

/*Insert some random maximum ID value*/
INSERT INTO MaxID VALUES (3423)

/*Insert fact values*/
INSERT INTO FactData VALUES (NULL,'Bob')
INSERT INTO FactData VALUES (NULL,'Dan')
INSERT INTO FactData VALUES (NULL,'Jane')

/*Insert more code here to give FactData id values. End result should
be that one row should be 3423, one should be
3424, one should be 3425. Doesn't matter which row is which, as long as
they have IDs*/


Thanks,
Kayda


[quoted text, click to view]
AddThis Social Bookmark Button