Archive for the ‘SQL Remote Query’ Category


SQL SERVER: Difference between OpenQuery and OpenRowSet


Today, one developer asked me what is the difference between OpenQuery and OpenRowSet.

Let me share this thing with all of you.

Syntax for both the command:

OPENQUERY ( linked_server ,’query’ )

( ‘provider_name’ , ‘datasource’ ; ‘user_id’ ; ‘password’
, { [ catalog. ] [ schema. ] object | ‘query’ }

Difference is:
OpenQuery uses a predefined linked server,
While OpenRowSet has to specify all the connection options. So with OpenRowSet you can query to your remote SQL server from local.

Else it’s the same.

Let me know if it helps you in any way.