Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Changing Primary key names to standard naming convention across the DB Expand / Collapse
Author
Message
Posted Wednesday, February 10, 2010 5:40 PM
SSC Eights!

SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!

Group: General Forum Members
Last Login: Sunday, May 11, 2014 8:07 PM
Points: 891, Visits: 235
Comments posted to this topic are about the item Changing Primary key names to standard naming convention across the DB


Post #863744
Posted Monday, March 1, 2010 2:16 PM
SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Wednesday, October 15, 2014 8:26 AM
Points: 2,080, Visits: 596
This could also be done simply using the INFORMATION_SCHEMA.TABLE_CONSTRAINTS view.

SELECT 'EXEC sp_rename ''[' + c.CONSTRAINT_SCHEMA + '].[' + c.CONSTRAINT_NAME + ']'', ' +
'''PK_' + c.TABLE_NAME + ''', ''OBJECT'' '
FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS c
WHERE c.CONSTRAINT_TYPE = 'PRIMARY KEY'
AND c.TABLE_NAME IS NOT NULL
ORDER BY c.TABLE_NAME

Post #874709
Posted Tuesday, March 2, 2010 9:40 PM
SSC Eights!

SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!

Group: General Forum Members
Last Login: Sunday, May 11, 2014 8:07 PM
Points: 891, Visits: 235
Yes !! this query is much simpler !!




Post #875666
Posted Friday, July 29, 2011 8:28 AM
Say Hey Kid

Say Hey KidSay Hey KidSay Hey KidSay Hey KidSay Hey KidSay Hey KidSay Hey KidSay Hey Kid

Group: General Forum Members
Last Login: Monday, April 7, 2014 11:41 AM
Points: 703, Visits: 4,519
I don't see the point.... if that's the 'standard' then the DB should have been developed that way to begin with. If the DB has had any code written against it, this will likely break a lot of it.... just saying...
Post #1150995
Posted Monday, September 29, 2014 3:42 AM
SSC Journeyman

SSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC Journeyman

Group: General Forum Members
Last Login: Thursday, October 9, 2014 5:37 AM
Points: 82, Visits: 179
I would add "WHERE ....... and '['+b.name+']'<>'[PK_'+a.name+']'" because my server likes to be lazy.
Post #1620726
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse