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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Searching on Text string that contains single quotes

Status
Not open for further replies.

ulicki

Technical User
Oct 24, 2001
88
0
0
US
Hi,

I cannot run the following query in Query Analyzer, I get an error:

SELECT NAME_LAST, OPT_ID,OPT_NUM FROM OPTIONEE WHERE OPT_ID = '999999999'AND UPPER(NAME_LAST) = 'O'BRIEN';

My problem is that the name O'BRIEN contains a single quote. How can I work around this?

Using SQL Server 2000.

Thanks
 
Use two quotes instead ('O''BRIEN').

------
"There's a man... He's bald and wears a short-sleeved shirt, and somehow he's very important to me. I think his name is Homer."
(Jack O'Neill, Stargate)
[banghead]
 
Hi,
Thanks for the reply,

It worked!!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top