SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Listing Tables and Indexes


Listing Tables and Indexes

Author
Message
SQLEnthusiastic
SQLEnthusiastic
Old Hand
Old Hand (399 reputation)Old Hand (399 reputation)Old Hand (399 reputation)Old Hand (399 reputation)Old Hand (399 reputation)Old Hand (399 reputation)Old Hand (399 reputation)Old Hand (399 reputation)

Group: General Forum Members
Points: 399 Visits: 104
Comments posted to this topic are about the item Listing Tables and Indexes
eddie 52254
eddie 52254
Grasshopper
Grasshopper (10 reputation)Grasshopper (10 reputation)Grasshopper (10 reputation)Grasshopper (10 reputation)Grasshopper (10 reputation)Grasshopper (10 reputation)Grasshopper (10 reputation)Grasshopper (10 reputation)

Group: General Forum Members
Points: 10 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
Iwas Bornready
Iwas Bornready
SSC-Dedicated
SSC-Dedicated (38K reputation)SSC-Dedicated (38K reputation)SSC-Dedicated (38K reputation)SSC-Dedicated (38K reputation)SSC-Dedicated (38K reputation)SSC-Dedicated (38K reputation)SSC-Dedicated (38K reputation)SSC-Dedicated (38K reputation)

Group: General Forum Members
Points: 38638 Visits: 886
Thanks for the script.
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum








































































































































































SQLServerCentral


Search