:::: MENU ::::

Accessing linked server data in SELECT or JOIN clause

  • Apr 25 / 2012
  • 0
dbDigger, Linked Servers and remote data, T-SQL Tips and Tricks

Accessing linked server data in SELECT or JOIN clause

Configured Linked servers allow to access heterogeneous and multiple source data. We may directly select, join the linked data with our local server data. Linked server may be configured for any OLEDB data source.
Once linked server is configured and working, here is a simple syntax to access its data in select or join  statement of T-SQL. For following linked server

Linked server name            DBASS2008
Database Name                    LinkedDB
Schema                                  dbo
Table                                      Linked table

To access the data in above provided linked server we would have to use fully qualified four part name pointing to linked server. It would be like [ServerName].[DBName].[SchemaName].[ObjectName]

select * from [DBASS2008].[LinkedDB].[dbo].[Linked table]

Same qualified syntax may be used while accessing data in join. If valid qualified syntax is not used then error message would be generated related to invalid object.

Consult us to explore the Databases. Contact us