March 15, 2012 at 5:34 pm
Hi everybody..i got a problem
i add a constraint PK1
Use test
GO
ALTER TABLE tablo1 ADD CONSTRAINT PK1 PRIMARY KEY (a1)
GO
how do I
Change the name of the constraint as PK1 PK2 Table1 a1 area
March 15, 2012 at 6:07 pm
Teh only way is to drop the constraint and rebuild it. Obviously, that becomes a real problem if you have other tables referencing that one through FKs. It's easier to do the change through SSMS because it'll determine the dependencies and do it all for you.
--Jeff Moden
Change is inevitable... Change for the better is not.
March 15, 2012 at 6:48 pm
thanks...i just started to sql
I do not know how to.
and
I tried these codes:
USE test
GO
EXEC sp_rename N'tablo1.PK1', N'PK2', N'a1';
GO
but gives an error message
Msg 15249, Level 11, State 1, Procedure sp_rename, Line 75
Error: Explicit @objtype 'a1' is unrecognized.
If you help for a solution I would be grateful
March 15, 2012 at 8:47 pm
i find script 😎
Use test
GO
sp_rename 'PK1', 'PK2', 'OBJECT'
GO
March 15, 2012 at 9:34 pm
hallo everyone,nice to meet you
March 15, 2012 at 10:33 pm
johnny1walker (3/15/2012)
i find script 😎Use test
GO
sp_rename 'PK1', 'PK2', 'OBJECT'
GO
Heh... well I'll be. Books Online has yet another documentation error. Under constraints, it specifically said that PK's needed to be dropped and rebuilt.
--Jeff Moden
Change is inevitable... Change for the better is not.
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply