Solved

InterSystems Caché OPEN QUERY

Posted on 2015-01-23
4
590 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
[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
  • 2
  • 2
4 Comments
 
LVL 18

Expert Comment

by:Simon
ID: 40566155
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
ID: 40566236
Thanks.

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

Author Comment

by:aneilg
ID: 40566242
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:Simon
ID: 40566243
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

Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

Question has a verified solution.

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

This article shows gives you an overview on SQL Server 2016 row level security. You will also get to know the usages of row-level-security and how it works
It is possible to export the data of a SQL Table in SSMS and generate INSERT statements. It's neatly tucked away in the generate scripts option of a database.
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

636 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