SQL Server: need to add primary key

I have about 5,000 records in a table in SQL Server 2008

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

How to add a primary key to each record?

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

+3
source share
1 answer

Try the following:

ALTER TABLE myTable ADD id INT IDENTITY
CONSTRAINT id _pk PRIMARY KEY;
+3
source

Source: https://habr.com/ru/post/1770795/


All Articles