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

Simple Select Statement to return data containing Single Quote

Status
Not open for further replies.

woogoob

Programmer
Jan 2, 2003
6
US
I have a table with some data that contains single quotes.

eg...
Table: tbl_Tools
Column ITEM
Data...
Garden Hose 50'
PVC Pipe 25"

Can someone tell me the SQL statement to return records that contain single quotes. I want to use 'IN' in the WHERE clause because I have a list of items i want to look for.

eg...
Select * from tbl_Tools Where Item IN ('Garden Hose 50'','PVC PIPE 25"')

The above statement fails because of the single quote in the data.

Thanks in advance,
Gary


 
Use two consecutive ' (single quote) characters inside a string (which is itself delimited with single quotes) to denote a literal ' character.

For example:

use pubs
select au_lname from authors where au_lname like '%''%'

au_lname
----------------------------------------
O'Leary

(1 row(s) affected)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top