I have a table with 8,000 rows of data and will be adding more. but I forgot to put a primary key in the beginning. so that each row has a unique key. later i added a primar
As per your requirement you just needed a sql query that will update the entire table with the new primary key values in an incremental fashion. Here is is :
UPDATE myTable
SET ID = ID + 1
Where ID is the PK field name
Once Updated do not forget to add identity column as shown below :
ALTER TABLE table
ADD ID INT IDENTITY
ALTER TABLE table
ADD CONSTRAINT PK_table
PRIMARY KEY(ID)