Unix Technical Forum

SQL Openquery & Oracle

This is a discussion on SQL Openquery & Oracle within the SQL Server forums, part of the Microsoft SQL Server category; --> In SQL Server 2000 I have set up an Oracle linked server. When I run the following query it ...


Go Back   Unix Technical Forum > Database Server Software > Microsoft SQL Server > SQL Server

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-29-2008, 09:09 AM
Chris
 
Posts: n/a
Default SQL Openquery & Oracle

In SQL Server 2000 I have set up an Oracle linked server. When I run
the following query it runs fine:-

SELECT
*
FROM
OPENQUERY(LINKEDSERVERNAME,'SELECT * FROM ORACLETABLENAME')

However the following query does not work:-

SELECT
*
FROM
OPENQUERY(LINKEDSERVERNAME,'SELECT FIELDNAME FROM ORACLETABLENAME')

This error is returned:-

Server: Msg 7321, Level 16, State 2, Line 1
An error occurred while preparing a query for execution against OLE DB
provider 'MSDAORA'.
[OLE/DB provider returned message: ORA-00904: "FIELDNAME": invalid
identifier
]
OLE DB error trace [OLE/DB Provider 'MSDAORA' ICommandPrepare::Prepare
returned 0x80040e14].

Basically select * works ok, but if I specify the field(s) I need then
it errors. I have tried entering the field names in upper and lower
case but it makes no difference.

My real problem is that some dates in the Oracle database are pre 1753
which SQL server does not recognise so I need to convert (decode) them.

Any help would be appreciated.

Thanks
Chris

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 02-29-2008, 09:10 AM
Erland Sommarskog
 
Posts: n/a
Default Re: SQL Openquery & Oracle

Chris (Chris.Tollisen@moorestephens.com) writes:
> In SQL Server 2000 I have set up an Oracle linked server. When I run
> the following query it runs fine:-
>
> SELECT
> *
> FROM
> OPENQUERY(LINKEDSERVERNAME,'SELECT * FROM ORACLETABLENAME')
>
> However the following query does not work:-
>
> SELECT
> *
> FROM
> OPENQUERY(LINKEDSERVERNAME,'SELECT FIELDNAME FROM ORACLETABLENAME')
>
> This error is returned:-
>
> Server: Msg 7321, Level 16, State 2, Line 1
> An error occurred while preparing a query for execution against OLE DB
> provider 'MSDAORA'.
> [OLE/DB provider returned message: ORA-00904: "FIELDNAME": invalid
> identifier
> ]
> OLE DB error trace [OLE/DB Provider 'MSDAORA' ICommandPrepare::Prepare
> returned 0x80040e14].
>
> Basically select * works ok, but if I specify the field(s) I need then
> it errors. I have tried entering the field names in upper and lower
> case but it makes no difference.


Which version of Oracle are you using? MSDAORA does not support Oracle10
very well. Maybe you should try Oracle's own OLE DB Provider.

Then again, it's very difficult to interpret that message as anything
else that there is no column FIELDNAME in table ORACLETABLENAME. Yet
then again, I don't know Oracle.

> My real problem is that some dates in the Oracle database are pre 1753
> which SQL server does not recognise so I need to convert (decode) them.


"CAST(datecol AS varchar)" or whichever syntax that is good on
Oracle for converting date values to strings.

--
Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 02-29-2008, 09:10 AM
DA Morgan
 
Posts: n/a
Default Re: SQL Openquery & Oracle

Erland Sommarskog wrote:
> Chris (Chris.Tollisen@moorestephens.com) writes:
>
>>In SQL Server 2000 I have set up an Oracle linked server. When I run
>>the following query it runs fine:-
>>
>>SELECT
>> *
>>FROM
>> OPENQUERY(LINKEDSERVERNAME,'SELECT * FROM ORACLETABLENAME')
>>
>>However the following query does not work:-
>>
>>SELECT
>> *
>>FROM
>> OPENQUERY(LINKEDSERVERNAME,'SELECT FIELDNAME FROM ORACLETABLENAME')
>>
>>This error is returned:-
>>
>>Server: Msg 7321, Level 16, State 2, Line 1
>>An error occurred while preparing a query for execution against OLE DB
>>provider 'MSDAORA'.
>>[OLE/DB provider returned message: ORA-00904: "FIELDNAME": invalid
>>identifier
>>]
>>OLE DB error trace [OLE/DB Provider 'MSDAORA' ICommandPrepare::Prepare
>>returned 0x80040e14].
>>
>>Basically select * works ok, but if I specify the field(s) I need then
>>it errors. I have tried entering the field names in upper and lower
>>case but it makes no difference.

>
>
> Which version of Oracle are you using? MSDAORA does not support Oracle10
> very well. Maybe you should try Oracle's own OLE DB Provider.
>
> Then again, it's very difficult to interpret that message as anything
> else that there is no column FIELDNAME in table ORACLETABLENAME. Yet
> then again, I don't know Oracle.
>
>
>>My real problem is that some dates in the Oracle database are pre 1753
>>which SQL server does not recognise so I need to convert (decode) them.

>
>
> "CAST(datecol AS varchar)" or whichever syntax that is good on
> Oracle for converting date values to strings.


Post at c.d.o.server and include Oracle version, hardware and operating
system, necessary DDL and DML so people will understand the environment.
--
Daniel A. Morgan
http://www.psoug.org
damorgan@x.washington.edu
(replace x with u to respond)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 10:55 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com