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

Listing Tables and Indexes Expand / Collapse
Author
Message
Posted Monday, December 17, 2007 7:37 AM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Monday, April 28, 2014 5:22 PM
Points: 196, Visits: 83
Comments posted to this topic are about the item Listing Tables and Indexes
Post #433872
Posted Monday, August 27, 2012 8:39 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Monday, October 8, 2012 10:52 AM
Points: 2, Visits: 6
Can someone tell me how to rename all DEV tables and it's indexes to LIVE nomenclature? Ex: ProductsDev to ProductsLive and all indexes renamed to Live extension as well.

Here is a query selecting what DEV tables and their indexes. I just need to put it in a loop for rename. Doing so keeps naming conventions correct and makes a generic method so if indexes are added sql code doesn't have to be maintained.

Any help is greatly appreciated.

/* Loop through all DEV tables and it's indexes */
SELECT b.name 'Table', a.name 'Index'
FROM sysindexes a, sysobjects b
WHERE a.id = b.id
and b.name like '%Dev'
and (a.name like 'PK%' or a.name like 'IX%')
and b.type = 'U'
and indid NOT IN (0, 255)
order by a.name
Post #1350433
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse