Solved

InterSystems Caché OPEN QUERY

Posted on 2015-01-23
4
415 Views
Last Modified: 2015-01-29
Hello.

I am trying to use an open query on InterSystems Caché through a linked server.


SELECT  *

FROM OPENQUERY([LinkedServer], 'SELECT * from Table')

error

OLE DB provider "MSDASQL" for linked server "INQUIRE" returned message "[Cache ODBC][State : 37000][Native Code 1]
[C:\Program Files\Microsoft SQL Server\MSSQL11.BISQL02\MSSQL\Binn\sqlservr.exe]
[SQLCODE: <-1>:<Invalid SQL statement>]
[Cache Error: <<SYNTAX>errdone+2^%qaqqt>]
[Details: <Prepare>]
[%msg: < SQL ERROR #1: IDENTIFIER expected, [ found^SELECT [ AccidentCode ] from [>]".
Msg 7321, Level 16, State 2, Line 4
An error occurred while preparing the query "SELECT [AccidentCode] from [ADMITDISCH]" for execution against OLE DB provider "MSDASQL" for linked server "INQUIRE".
0
Comment
Question by:aneilg
  • 2
  • 2
4 Comments
 
LVL 18

Expert Comment

by:SimonAdept
Comment Utility
1. You need to include the schema name as well as the table.

Here's an example of a working query:
select * from openquery(kbsql_XXXX,'Select count(*) from R.MEDRECS_HISTORY')

Open in new window


Which version of the ODBC driver to you have and is it 32bit or 64bit?
0
 

Accepted Solution

by:
aneilg earned 0 total points
Comment Utility
Thanks.

Does not seem to like *, you not to select individual tables.
0
 

Author Comment

by:aneilg
Comment Utility
I've requested that this question be closed as follows:

Accepted answer: 0 points for aneilg's comment http:#a40566236

for the following reason:

partly answered.
0
 
LVL 18

Expert Comment

by:SimonAdept
Comment Utility
hi aneilg, sorry I didn't quite understand your last comment or close request reason...

select * from openquery(kbsql_XXX,'Select * from r.tablename')

...does work (provided that the meta-data is correct in the data dictionary for that table).
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
t-sql complement 8 29
Save sql query result in sql server 15 22
INSERT INTO SELECT JOIN THING 2 24
Sql query to Stored Procedure 6 13
The Delta outage: 650 cancelled flights, more than 1200 delayed flights, thousands of frustrated customers, tens of millions of dollars in damages – plus untold reputational damage to one of the world’s most trusted airlines. All due to a catastroph…
For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed

743 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

8 Experts available now in Live!

Get 1:1 Help Now