I have two Sql Server 2008 R2 databases, called MyDbOne
and MyDbTwo
.
I'd like to merge them (all tables and procedures) into a new database called MyDb
.
Assume there are no conflicts in table and procedure names between them.
The problem is: there are LOTS of code and procedures that execute queries using the database name, including procedures declared in one of the databases referecing tables from the other. There are queries like:
select * from MyDbOne..SomeTable;
select * from MyDbTwo..AnotherTable;
The tables SomeTable
and AnotherTable
would then exist in the MyDb
database. But I need to support querying them using the leagcy names MyDbOne
and MyDbTwo
. If I would run the queries above, I'd like them to be effectively the same as:
select * from MyDb..SomeTable;
select * from MyDb..AnotherTable;
Is there some way to do it? Maybe create some sort of global aliases on the new database, resolving MyDbOne
and MyDbTwo
to MyDb
? That would be perfect, but I don't know how to do it.
Thank you ver much!