title: SQL Server Linked Database Aliases
body: <p>Is it possible to have not only a LinkedServer, but linked database and server?
  My situation is that of having one environment with a setup of:</p>
  
  <p>ServerX: DatabaseOne,
           DatabaseTwo</p>
  
  <p>and another environment of:</p>
  
  <p>ServerY: MyDatabaseOne,
           MyDatabaseTwo</p>
  
  <p>Now, DatabaseOne and MyDatabaseOne are exactly the same, as are DatabaseTwo and MyDatabaseTwo.
  I have a stored procedure that does some basic table updates from one db to the other on a given server, and I want it to be able to work in both evironments. I have set up a linked server so my reference can be:</p>
  
  <p>MyLinkedServer.DatabaseOne.dbo.MyTable or MyLinkedServer.MyDatabaseOne.dbo.MyTable</p>
  
  <p>Even with this though, I will need to change the SP when I switch environments to change the db names, is there any way of setting up a Database Alias, so that I can write:</p>
  
  <p>SELECT * FROM MyLinkedServer.MyLinkedDatabase.dbo.MyTable</p>
  
  <p>So that as long as LinkedServer and (if possible) LinkedDatabase are set up in each environment, the SP will work without changing when switching environments?</p>