Sunday, March 25, 2012

Configuration fIle

I'm using stored procedures in a database that use data in other databases. I refer these data as DataBaseName.dbo.TableName. It works fine. But, i just thought, what if the name of the databases change?

Is there anyway to use some sort of variables to refer the databases? like a configuration file used in programming applications.

Thanks

You can do one of the below:

1. In SQL Server 2005, you can create synonyms for the tables in the other database. And when the name of the database changes you will have to drop & recreate the synonym

2. In older versions of SQL Server, you can create views that point to the tables in the other database and do the same.

No comments:

Post a Comment