From: Duke Carey on
Plamen - thanks for the pointer. I hate to sound dense, but if the synonym
could be used to identify a database it would be perfect. However, the
article and related links appear to state you can only create synonyms for
objects within a database, not the db itself.

I need help with the case where the view [and other objects] originally
referenced numerous tables in the form of:

OriginalDBName.dbo.[some table name]

and they must be changed to:

SomeOtherDBName.dbo.[some table name]

Am I left only with the option of doing a search and replace on a series of
ALTER object scripts?



"Plamen Ratchev" wrote:

> Take a look at synonyms:
> http://msdn.microsoft.com/en-us/library/ms177544.aspx
>
> --
> Plamen Ratchev
> http://www.SQLStudio.com
> .
>
From: Plamen Ratchev on
If you use synonyms all of your code will reference the synonyms and only the synonym definition will reference the
database object by database. Then you can change only the synonyms, but not the code, for different databases.

Like:

CREATE SYNONYM dbo.[some table name synonym] FOR OriginalDBName.dbo.[some table name];

Then in all your code you use:

SELECT <columns> FROM dbo.[some table name synonym];


--
Plamen Ratchev
http://www.SQLStudio.com
From: Duke Carey on
Oh, OK. That makes good sense. I'll work on that approach. Thanks so much!

"Plamen Ratchev" wrote:

> If you use synonyms all of your code will reference the synonyms and only the synonym definition will reference the
> database object by database. Then you can change only the synonyms, but not the code, for different databases.
>
> Like:
>
> CREATE SYNONYM dbo.[some table name synonym] FOR OriginalDBName.dbo.[some table name];
>
> Then in all your code you use:
>
> SELECT <columns> FROM dbo.[some table name synonym];
>
>
> --
> Plamen Ratchev
> http://www.SQLStudio.com
> .
>