Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Correct use of single and double quotes 1

Status
Not open for further replies.

tgriffin

Programmer
Jan 18, 2001
20
0
0
US
I am using SQL's OPENQUERY to an Oracle server. This is a little of what I am using
SELECT * FROM OPENQUERY(OracleSrv, 'Select A, B, C FROM D where A = "something"').

I keep getting an invalid column name error when I do this. I can run this is Access and it works fine. Am I using the wrong syntax for the single/double quotes? Originally, before using the OPENQUERY the second select statement wasn't in any quotes except for single quotes around the word something ('something'). When I put the single quotes around the whole second select statement as required, I thought that the single quotes around 'something' had to be changed to double quotes. If I don't change them and run the query, then I do get an error. But I am also getting an error if I do both. Any suggestions?

Thanks!

 
try this

SELECT * FROM OPENQUERY(OracleSrv, 'Select A, B, C FROM D where A = ''something''')

or this

SELECT * FROM OPENQUERY(OracleSrv, 'Select [A],,[C] FROM [D] where [A] = ''something''')

or this

SELECT * FROM OPENQUERY(OracleSrv, 'Select [A],,[C] FROM [D] where [A]=''something''')

or this

SELECT * FROM OPENQUERY(OracleSrv, "Select [A],,[C] FROM [D] where [A]='something'")

or this

SELECT * FROM OPENQUERY(OracleSrv, "Select [A],,[C] FROM [D] where [A]=""something""")

 
Thanks keith....I figured it out and it was #4 on your list! Too bad I didn't look here after you posted! :)


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top