Solved

OPENQUERY vs. OPENROWSET

Posted on 2007-04-09
3
3,222 Views
Last Modified: 2012-06-21
Can someone explain to me what do OPENQUERY and OPENROWSET do, how and when are they used and what is the difference between the two. Please do not provide links to articles, I tried reading different articles but still cannot completely understand those two
0
Comment
Question by:YZlat
3 Comments
 
LVL 142

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 250 total points
ID: 18876951
syntax:

OPENQUERY ( linked_server ,'query' )

OPENROWSET
( { 'provider_name' , { 'datasource' ; 'user_id' ; 'password'
   | 'provider_string' }
      , {   [ catalog. ] [ schema. ] object
       | 'query'
     }
   | BULK 'data_file' ,
       { FORMATFILE = 'format_file_path' [ <bulk_options> ]
       | SINGLE_BLOB | SINGLE_CLOB | SINGLE_NCLOB }
} )

so, openquery uses a predefined linked server, while openrowset has to sepcify all the connection options.

for the rest, it's the same

0
 
LVL 35

Author Comment

by:YZlat
ID: 18877038
thanks Angel!
0
 

Expert Comment

by:hpsuser
ID: 23006165
One quick comment:  In limited experience using both, I have found that OpenRowSet can perform better (some queries that bomb out using OpenQuery after a while because of resource issues run using OpenRowSet)....I haven't done enough testing to know for sure that this is the cause was OPENQUERY vs. OPENROWSET, but FWIW I always use OpenRowSet when possible.
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

When you hear the word proxy, you may become apprehensive. This article will help you to understand Proxy and when it is useful. Let's talk Proxy for SQL Server. (Not in terms of Internet access.) Typically, you'll run into this type of problem w…
Let's review the features of new SQL Server 2012 (Denali CTP3). It listed as below: PERCENT_RANK(): PERCENT_RANK() function will returns the percentage value of rank of the values among its group. PERCENT_RANK() function value always in be…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Via a live example, show how to shrink a transaction log file down to a reasonable size.

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now