2

I've searched for this in quite a few areas, but haven't found a crystal clear answer to this.

I am working with multiple database servers and am consistently writing out [ServerName].[databasename].dbo.TableName. I know you can alias a table, but I can't find a definite answer on server and database.

Is it possible to create an alias that allows me to call the alias rather than calling the entire [ServerName].[databasename].dbo.TableName?

As an example: Server Name: SQL01 Database name: Client Desired Alias: Client

Sample table name on SQL01.Client: Contact

From SQL02, can I call Client.Contact like SELECT * FROM Client.Contact rather than having to write SELECT * FROM [SQL01].Client.dbo.Contact?

mikebmassey
  • 8,354
  • 26
  • 70
  • 95

1 Answers1

1

If you haven't already come across it, the key word you're looking for is "synonym", and the documentation describes exactly the scenario you're interested in. So yes, it is possible.

Pondlife
  • 15,992
  • 6
  • 37
  • 51