Is there a way to query a DB2 Linked Server without using Openquery? IE, is it possible to query DB2 through a linked server by doing something like the following?

select *
from [db2_linked_server].[database].[tablename]

1 Answer 1


Assuming your linked server provider supports it, you should be able to use a 4-part name (your example only used 3-parts)

I'm referencing Transact-SQL Syntax Conventions-Transact-SQL.

server_name .[database_name].[schema_name].object_name


server_name Specifies a linked server name or remote server name.

database_name Specifies the name of a SQL Server database when the object resides in a local instance of SQL Server. When the object is in a linked server, database_name specifies an OLE DB catalog.

schema_name Specifies the name of the schema that contains the object if the object is in a SQL Server database. When the object is in a linked server, schema_name specifies an OLE DB schema name.

object_name Refers to the name of the object.

  • However, understand that accessing a DB2 linked server via 4-part name means that MS SQL Server pulls back the entire table and does any WHERE clause locally. Whereas with OPENQUERY, the entire statement is sent to the remote server and the WHERE clause is done on the remote server.
    – Charles
    Commented Apr 17, 2017 at 15:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.