update: This is more of a maintenance issue than the normal case.
I have the following table:
CourseId StudentId
---------------------
1 1
1 2
2 1
CourseId and StudentId are composite primary key.
Let’s say I wanted to update where courseid=1 to courseid=2 for some reason. This will cause a primary key constraint issue.
What are some different ways you could solved this?
Run the UPDATE statement:
Remove duplicates – this solution assumes SQL Server 2005+:
Enable/recreate the primary key