Search code examples
sqlaliaslinked-server

How to shorten paths when accessing linked-server objects in SQL


Is there a way to shorted access paths in SQL? I am thinking something similar to alias's but I don't know how to ask this question in google to get the appropriate application of alias'ing

This:

  select * from ServerName.DBName.dbo.TableName

To:

  declare @RDB as RemoteDatabaseObject
  set @RDB = ServerName.DBName.dbo

  select * from @RDB.TableName

I know this doesnt work, but I want to know if there is a way to alias objects that have long paths.


Solution

  • Maybe you are looking for SYNONYM?

    http://msdn.microsoft.com/en-us/library/ms177544.aspx