Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 664
  • Last Modified:

InterSystems Caché OPEN QUERY

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
aneilg
Asked:
aneilg
  • 2
  • 2
1 Solution
 
SimonCommented:
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
 
aneilgAuthor Commented:
Thanks.

Does not seem to like *, you not to select individual tables.
0
 
aneilgAuthor Commented:
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
 
SimonCommented:
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now