Refactor table to view

Refactors and formats SQL code.

Moderators: Chris Auckland, David Atkinson, Anu Deshpande, Luke Jefferson

Refactor table to view

Postby neilx » Thu Jul 23, 2009 3:10 pm

If I want to rename a table and use a view in its place to prevent applications from breaking, how can I do this?

If I use smart rename, then absolutely everywhere the table is mentioned is changed. Could I limit the changes to tables only (e.g. relationships and triggers) and then create a view with the original name of the table?

Would I be better off scripting the database, creating the view in the script then renaming the table name occurences mainually so I can choose only the occurences I want?
neilx
 
Posts: 8
Joined: Fri Apr 20, 2007 9:08 am

Postby Anu Deshpande » Fri Jul 24, 2009 12:07 pm

Thanks for your post.

Yes you can follow the below mentioned steps:

1. Rename the table with view.
2. Follow the <Smart Rename> wizard and SQL Refactor will generate the script for the rename of that object.
3. You can than manually remove the queries where you do not want the object rename to be executed.

Kindly let us know if that helped.
Anuradha Deshpande
Product Support
Redgate Software Ltd.
E-mail: support@red-gate.com
Anu Deshpande
 
Posts: 692
Joined: Mon Apr 20, 2009 3:53 pm
Location: Cambridge


Return to SQL Refactor 1

Who is online

Users browsing this forum: No registered users and 0 guests

cron