Solved

InterSystems Caché OPEN QUERY

Posted on 2015-01-23
4
547 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

Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

Question has a verified solution.

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

This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
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
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties

710 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