Blog Detail

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' )
OPENROWSET 
( '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.

About me

User

Tejas Shah

Microsoft Certified Professional Expert. I have 14+ years of experience in Design and Develop 100+ .Net applications using Asp.Net, C#, Asp.Net Core, VB.Net, SQL Server, MVC, AngularJS, JavaScript, Azure, HTML5 and CSS3.

Recent Post