I am doing a refactor of a database. In this process I am renaming some of the existing tables, keys and constraints. They will be recreated on the new refactored tables. Then data will be moved to the new tables before dropping the old tables.
I have one foreign key when I try to use Exec sp_rename
I get an error back the object does not exist.
If I try to use print object_id('xxx')
I get nothing back.
It is a valid object and I can find it in the sys.objects table
.
If I try to use print Object_Name('123456789')
with the object id from the sys.objects
table it returns the name I am using in the sp_rename
.
Any one got an idea why the sp_rename
can not find the object?
Thanks but I get this error "Either the parameter @objname is ambiguous or the claimed @objtype (OBJECT) is wrong.". I believe the issue is some how when I created the foreign key the Schema name 'dbo.' is actually part of the name of the object. So when I exec the sp_rename it looks in Schema dbo for FK_FRP_File_DataMatrix which doesn't exist. The name really is dbo.FK_FRP_File_DataMatrix in the objects table. If I manually remove the dbo. from the name under Keys then and rename it. Need to fix this on my production database.