"Alias" a database

Last Post 06 Aug 2008 09:04 AM by SwePeso. 3 Replies.
AddThis - Bookmarking and Sharing Button
Author Messages
SQLScott
New Member
New Member

--
14 Feb 2007 08:01 AM
Is there any way to "alias" a database? Let me explain...

Our application has two databases. The main "production" database and an archive database. We have a process in which database is "archived" from the production db to the archive db. However, we can't always guarantee that the archive db will always be called the same thing.

So, we want to be able to Alias it so that the code in the production db never needs to be changed.

Does this make sense?

Any input is greatly appreciated...
SQLScott
New Member
New Member

--
14 Feb 2007 08:49 AM
Synonyms is the answer. You can even "alias" objects in a database on a different server.
SQLUSA
New Member
New Member

--
13 Jul 2008 10:27 PM
Make sure you test it out with synonyms.

Your requirement makes sense.

Still the DBA has to apply caution and vigilance. If the db mapping is wrong, the code will no longer "complain".

Kalman Toth - Database, Data Warehouse & Business Intelligence Architect
SQL Server 2005 Training, SSAS, SSIS, SSRS: http://www.sqlusa.com/
SwePeso
New Member
New Member

--
06 Aug 2008 09:04 AM
quote:

Originally posted by: SQLUSA
Make sure you test it out with synonyms.


quote:

From Books Online
Synonyms can be created for the following types of objects:

Assembly (CLR) Stored Procedure
Assembly (CLR) Table-valued Function

Assembly (CLR) Scalar Function
Assembly Aggregate (CLR) Aggregate Functions

Replication-filter-procedure
Extended Stored Procedure

SQL Scalar Function
SQL Table-valued Function

SQL Inline-table-valued Function
SQL Stored Procedure

View
Table1 (User-defined)


1 Includes local and global temporary tables



It seems databases cannot be aliased with synonym.


Acceptable Use Policy
---