tags:

views:

33

answers:

1

I have about 5000 records in a table in SQL Server 2008

I need to add a primary key. I don't care what it is, maybe an autonumber would be best?

How do I add a primary key to every record ?

I also would like this primary key to be generated automatically when I add new rows!

+3  A: 

Try this:

ALTER TABLE myTable ADD id INT IDENTITY
CONSTRAINT id _pk PRIMARY KEY;
Abe Miessler
thank you sir! have a wonderful shabbas
i am a girl