OPENQUERY is a T-SQL function that allows for executing a pass-through query on a linked server. The linked server should be an OLE DB data source. OPENQUERY is used in SELECT, INSERT, DELETE and UPDATE statements as if it were a table name.
Questions tagged [openquery]
421 questions
1
vote
1 answer
SQL Msg 7303, Level 16, State 1, Line 3 Cannot initialize the data source object of OLE DB provider "VFPOLEDB"
I have a 32bit SQL Server 2014 Express (BenVM) set up on a virtual machine running Windows 7 64bit. This instance of SQL Server has a linked server connected to it called MSCRIBE2 using the VFPOLEDB (foxpro) provider. From my virtual machine I am…

Ben
- 37
- 1
- 7
1
vote
0 answers
All Query Conditions being satisfied in OpenQuery SQL command but it is still not behaving correctly
So I have a query I've written that I thought was working, but just found out today that it isn't. The goal is to sync a user database on one SQL server with another on a MYSQL server so our web server can query it quicker than if it were trying to…

TheEggSample
- 333
- 4
- 5
- 18
1
vote
1 answer
Openquery Hung at Same Row Number
I'm attempting to do run an openquery in SQL Server 17 via a linked server to an Oracle connection feed. When I run the query posted below it gets stuck at row 7833 every single time.
Query:
SELECT
sys_ohi,
"Region",
sub_acct_no_ohi,…

cbrown92
- 13
- 4
1
vote
0 answers
SQL Server stored procedure using OpenQuery - select from as table
I am trying to select from a PostgreSQL database to SQL Server 2008 over a linked server. I have created a stored procedure (dynamic using OpenQuery) which returns what I am wanting. Now, though, I need to join the results to another table and keep…

L.Nelson
- 21
- 3
1
vote
2 answers
Does the query from the linked server still continue even though you have obtained your result in your SQL Server?
Let's say you have a link server X.
If you were to get 1 row from X in a table (apples) from a schema (fruit). Assuming that the table has a billion rows.
Select TOP 1 * from openquery(X , 'SELECT * FROM fruit.apples')
Does the query still…

Dip
- 343
- 7
- 22
1
vote
1 answer
OPENQUERY MDX query is very slow during cube processing
I have multiple cubes on SSAS server and few cubes which are 10GB+. One of .NET apps is accessing relatively small cube <1GB cube via OPENQUERY.
When one of big cubes is processing (36GB+) .NET application timeouts as there is default timeout in…
user170442
1
vote
2 answers
Use embedded TSQL exec string to generate output parameters for SSRS report
I'm working with SQL Server 2012 and SSRS. Using this very useful answer, I have a parameterized query working that pulls data from a DB2 system through openquery. I'd like to make this into an SSRS report. I don't see how to do it with a query,…

Mike Christie
- 381
- 1
- 10
1
vote
1 answer
How to do OpenQuery in mongoDB
I want to do link mongodb servers within one query like SQL Linked server's OpenQuery concept. Is it possible in mongoDB?
SELECT
UserID,
UserName,
FirstName,
LastName
FROM OPENQUERY(remotelinkedservername, 'SELECT * FROM dbo.Users'…

Murugan Perumal
- 975
- 5
- 15
1
vote
1 answer
SQL: OPENQUERY Question
I am currently using OPENQUERY to import Data into a Database from an Oracle Linked Server.
I am currently using SELECT INTO. It works well, but I have to drop the database and recreate it everytime i need to import the data or else i get the…

asd
- 15
- 1
- 4
1
vote
1 answer
Direct linked server querying VS querying via openquery
In SQL Server Management Studio, I have created a linked server to another SQL Server. The name of the linked server that I created is "linkedserver". The linked server uses the Microsoft OLE DB provider. However, the problem described below occurs…

aragorn
- 187
- 3
- 18
1
vote
0 answers
Is there an advantage to using OPENQUERY when syntax doesn't require it?
Assume a query that contains something like
set @x = max([column]) from [table]
insert into [table]
select * from [linkedserver].[database].dbo.[table] where [column]>@x
Is there an advantage to using OPENQUERY here instead of the 'direct'…

Luc VdV
- 1,088
- 9
- 14
1
vote
1 answer
sql server with openquery using count(*) against sqlite
I have sqlite database connected through linked server in sql server.
Following query works just fine:
select *
from openquery(
eod,
'select id, min(dt) as mindt, max(dt) as maxdt from [tdata] group by id'
)
But this query returns an…

Michael EstrinOne
- 429
- 2
- 11
1
vote
2 answers
Microsoft SQL Server - Open Query where > date
I am trying to run a select using openquery with filtering result by date, but I have problem with using the date after where clause.
Ideally I would like to be able to pass a variable
set @d = dateadd(day, -30, getdate())
but for the sake of…

Adrian
- 347
- 1
- 6
- 18
1
vote
1 answer
ADSI - Query Custom User Attribute through SQL Server Is Failing
I created 4 custom attributes in my Active Directory. I followed the instructions as found here - https://social.technet.microsoft.com/wiki/contents/articles/20319.how-to-create-a-custom-attribute-in-active-directory.aspx
I can see the attributes in…

wruckie
- 1,717
- 1
- 23
- 34
1
vote
2 answers
MS SQL - MySQL - Openquery Chinese characters imported as '?'
I am importing data from a MySQL Database into a Microsoft SQL Server Database (SQL_Latin1_General_CP1_CI_AS). I use a linkedserver connection based on OBDC in combination with an Openquery statement.
I use the following MS SQL Statement:
SELECT…

phicon
- 3,549
- 5
- 32
- 62