Solved

OPENQUERY vs. OPENROWSET

Posted on 2007-04-09
3
3,499 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 143

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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

JSON is being used more and more, besides XML, and you surely wanted to parse the data out into SQL instead of doing it in some Javascript. The below function in SQL Server can do the job for you, returning a quick table with the parsed data.
Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

687 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