I was wondering if there was a way to set an alias up so that, when the table is moved, there will be no problems with out code still trying to access the table from the old database.
Maybe an example is the best way to explain this. Lets say we have a DB_Company database with table T_Customers, T_Suppliers, etc.
Now, as the company grows, we decide to create a dedicated database for all the customers. So we create a database DB_Customers and move the T_Customers table into it.
The problem is that they may be some code that is still trying to access the DB_Company.T_Customers table. Is there a way of setting an alias up so that, when someone tries to access the DB_Company.T_ Customers table, he is automatically redirected to the DB_Customers.T_Customers?
Hope that's not too confusing :-(
Jag
Hi jagdipa,
I don't think (AFAIK) you can do an alias to the tables...But you can first check the db objects w/c depends on the table, by using the sp_depends '<tablename>' stored proc. and will display to you its dependencies.. and change as needed..
or
after getting the dependcies wrap the table into a view so that you don't need change the name in the dependencies..
HTH
|||Thanks Bonskijr, but that its not possible.I am a great believer in using views and never accessing the tables directly. Unforuanetly, the people before me did not. There could be many pages that access the tables directly.
Edit: I just read your post properly. The second idea is very good. I will have a look into that. Thanks alot.
No comments:
Post a Comment