Tuesday, March 27, 2012

Alias a linked server

Is there any way to alias a database on a linked server, so that if the
server name ever changed, I could just update the alias so that stored
procedures would not get broken?
for example, I have database1 on server1. On server2 i have a stored proc
that has a statement select * from server1.database1.dbo.table1 I'd rather
have some sort of alias so that my stored proc could be select * from
aliasname.dbo.table1 so if the database ever moved servers, i could just
update the alias on server2, and any stored proc that referenced the alias
would still work. Is this possible?Hi,
if you write server1.database1.dbo.table1, server1 does not have to be
the machine name - it is just the name you passed to sp_addlinkedserver.
So if your machine name changes, just update the record in
master..sysservers via the appropriate SPs.
However, the name of the database must be the same on both machines.
/Jo
Jeremy Chapman wrote:

> Is there any way to alias a database on a linked server, so that if the
> server name ever changed, I could just update the alias so that stored
> procedures would not get broken?
> for example, I have database1 on server1. On server2 i have a stored pro
c
> that has a statement select * from server1.database1.dbo.table1 I'd rath
er
> have some sort of alias so that my stored proc could be select * from
> aliasname.dbo.table1 so if the database ever moved servers, i could just
> update the alias on server2, and any stored proc that referenced the alias
> would still work. Is this possible?
>

No comments:

Post a Comment