Change primary key column in SQL Server
Assuming that your current primary key constraint is called pk_history, you can replace the following lines: ALTER TABLE history ADD PRIMARY KEY (id) ALTER TABLE history DROP CONSTRAINT userId DROP CONSTRAINT name with these: ALTER TABLE history DROP CONSTRAINT pk_history ALTER TABLE history ADD CONSTRAINT pk_history PRIMARY KEY (id) If you don’t know what the … Read more