brooksmato
asked on
Proper syntax for TSQL openquery statement
From SQL Server 2005, I am able to query a linked Oracle 10g database with this:
select * from openquery(dgo1,'select * from DGOUSER.HOUSEHOLD')
I'm trying to add a where clause
select * from openquery(dgtest,'select * from dgtable.house where upper(LAST_NAME) = 'SMITH' ')
The error I get is:
Msg 102, Level 15, State 1, Line 1
Incorrect syntax near 'SMITH'.
What do I have to correct to get the query to work?
select * from openquery(dgo1,'select * from DGOUSER.HOUSEHOLD')
I'm trying to add a where clause
select * from openquery(dgtest,'select * from dgtable.house where upper(LAST_NAME) = 'SMITH' ')
The error I get is:
Msg 102, Level 15, State 1, Line 1
Incorrect syntax near 'SMITH'.
What do I have to correct to get the query to work?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
not double quotes ("), the single quotes ('')
looks like the same, but is not.
looks like the same, but is not.
ASKER
Angellll-
You rock! Thanks a bunch.
Brooks
You rock! Thanks a bunch.
Brooks
ASKER
select * from openquery(dgtest,'select * from dgtable.house where upper(LAST_NAME) = ''SMITH'' ')
Gives me this error now.
OLE DB provider "MSDAORA" for linked server "dgtest" returned message "ORA-00904: "SMITH": invalid identifier
".
Msg 7321, Level 16, State 2, Line 1
An error occurred while preparing the query "select * from dgtable.house where upper(LAST_NAME) = "SMITH" " for execution against OLE DB provider "MSDAORA" for linked server "dgtest".