Trying to rename foring key in MS SQL using
sp_rename 'FK_Catalog_Equipment__Equiements_Catalog_Client_Clients','FK_Catalog_Equipment__Equipments_Catalog_Client_Clients','OBJECT'
or
sp_rename 'Table_Name.FK_Catalog_Equipment__Equiements_Catalog_Client_Clients','FK_Catalog_Equipment__Equipments_Catalog_Client_Clients','OBJECT'
but both commands result in
Msg 15248, Level 11, State 1, Procedure sp_rename, Line 359
Either the parameter @objname is ambiguous or the claimed @objtype (OBJECT) is wrong.
What I do wrong?
You can change foreign keys for your table or nickname. A foreign key is a column or set of columns in a table or nickname whose values are required to match at least one primary key value of a row of its parent table or nickname.
to update an entity attribute Identifier as a foreign key, you have to remove the referential integrity of the First table means which needs to update and also need to delete all the data of this Table. Then it can be done.
sp_rename automatically renames the associated index whenever a PRIMARY KEY or UNIQUE constraint is renamed. If a renamed index is tied to a PRIMARY KEY constraint, the PRIMARY KEY constraint is also automatically renamed by sp_rename . sp_rename can be used to rename primary and secondary XML indexes.
RENAME OBJECT [::] [ [database_name . [ schema_name ] . ] | [ schema_name . ] ] table_name COLUMN column_name TO new_column_name.
Foreign key constraints are individual objects, which is why you can't have a FK with the same name as other objects. Therefore, their name is relevant to the schema.
Copying from sp_rename's documentation example:
sp_rename 'HumanResources.FK_Employee_Person_BusinessEntityID', 'FK_EmployeeID';
will rename FK_Employee_Person_BusinessEntityID
found in the HumanResources
schema to FK_EmployeeID
If the schema is missing, SQL Server looks for objects in the user's default schema, which is often the dbo
schema. If the FK is created in a different schema, you need to specify it explicitly
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With