Sql updating primary key value
Restrictions: You cannot defer a NOT DEFERRABLE constraint with the SET CONSTRAINT(S) statement.
FK_DRT555_PROCNUM_LCNCOD) violated - parent key not found Elapsed: .02 [email protected] Most people do not -- it fails the commit and I'll betcha most applications would not deal with that nicely -- they are not expecting a commit to fail.
If a table already exists, you can add PRIMARY KEY constraint, provided that no other PRIMARY KEY constraint already exists. If a PRIMARY KEY constraint already exists, you can modify or delete it.
For example, you may want the PRIMARY KEY constraint of the table to reference other columns, or you may want to change the column order, index name, clustered option, or fill factor of the PRIMARY KEY constraint.
Additionally, if a data relation is based on the primary key, related foreign key fields in the child tables will have to be updated to maintain referential integrity.
You can modify a primary key in SQL Server 2017 by using SQL Server Management Studio or Transact-SQL.