KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: Using Open Query from a MS SQL Server linked server
PRODUCT: 4D | VERSION: 14.x | PLATFORM: Win
Published On: March 7, 2016

When using 4D as a linked server from MS SQL Server, there are multiple ways to SELECT data from the linked server. One of these ways is to use the Open Query syntax.

When using the Open Query syntax, you will first want to enable the OpenQuery Compatibility option at the DSN:


Adding the linked server in MS SQL Server can be accomplished using the following script:

EXEC sp_addlinkedserver
@server = 'Your4DAppName',
@srvproduct = 'Anything',
@provider = 'MSDASQL',
@provstr = 'OpenQuery=true;dsn=A_4D_DSN;UID=your4DUser;PWD=ThePassword'


Then you can query the linked server from MS SQL Server using the Open Query syntax like so:
SELECT * FROM OPENQUERY(My4DLinkedServer, 'SELECT name, id FROM titles')