I just moved my Member
table from MRK
schema to GNR
.
I previously had the script below to set its primary key:
If not Exists (select 1
from sys.objects
where name = 'PK_MRK_Member'
)
ALTER TABLE [MRK].[Member]
ADD CONSTRAINT [PK_MRK_Member] PRIMARY KEY CLUSTERED
(
[MemberID] ASC
) ON [PRIMARY]
GO
How do I change the name AND the schema of the defined constraint now?
I tried exec sp_rename 'PK_MRK_Member', 'PK_GNR_Member', 'INDEX'
for changing the name, but get this error:
Either the parameter @objname is ambiguous or the claimed @objtype (INDEX) is wrong.
P.S.: I cannot drop the table and/or the PK constraint and create them again since they PK is already in use by other tables.