Friday, March 30, 2012

Renaming a Table

Is there a way to rename a table in a database without breaking all the
relationships, views etc.?
Is there any procedure which would search the DB for references to the old
table name and change them to the new one?
Thanks
To display recorded dependencies you can use sp_depends. This may not list
everything though. To be sure, you could use EM to generate a script of all
objects in the database and then do a textual search on the script. An an
interim measure, you could rename the table then create a view with the old
tablename as its name which does a select * from the new tablename, while
you point the other objects towards the new table.
HTH,
Paul Ibison
sql

No comments:

Post a Comment