SELECT SINGLE QUOTE STATEMENT?

SELECT SINGLE QUOTE STATEMENT?

Post by JEFF » Thu, 15 Aug 2002 00:03:12



HOW DO I WRITE A SELECT STATEMENT THAT SEARCHES FOR A
SINGLE QUOTE (')?
I HAVE A COL IN A TB THAT CONTAINS DATA SUCH AS DE'ANGLIO
AND SMITH'S.  I NEED TO LOCATE THESE RECORDS WITH SINGLE
QUOTES IN THEM.
THANK
JEFF
 
 
 

SELECT SINGLE QUOTE STATEMENT?

Post by Anith Se » Thu, 15 Aug 2002 00:09:27


A sample here:

USE Pubs
GO
SELECT  *
  FROM  authors
 WHERE  au_lname LIKE '%''%'

--
- Anith

 
 
 

SELECT SINGLE QUOTE STATEMENT?

Post by Aaron Bertrand [MVP » Thu, 15 Aug 2002 00:09:15


First, you can turn off ALL CAPS.  My ears hurt.

Next, double-up single quotes, e.g. SELECT column FROM table WHERE name =
'DE''Angelo'

--
www.aspfaq.com / www.perfhound.com


Quote:> HOW DO I WRITE A SELECT STATEMENT THAT SEARCHES FOR A
> SINGLE QUOTE (')?
> I HAVE A COL IN A TB THAT CONTAINS DATA SUCH AS DE'ANGLIO
> AND SMITH'S.  I NEED TO LOCATE THESE RECORDS WITH SINGLE
> QUOTES IN THEM.
> THANK
> JEFF

 
 
 

SELECT SINGLE QUOTE STATEMENT?

Post by Steve Kas » Thu, 15 Aug 2002 00:16:46


Jeff,

select * from T where yourColumn like '%''%'

A single quote is represented in a literal string by typing two single
quotes in a row.  Alternately you can refer to the single quote as
char(39):

select * from T where yourColumn like '%'+char(39)+'%'

Steve Kass
Drew University


> HOW DO I WRITE A SELECT STATEMENT THAT SEARCHES FOR A
> SINGLE QUOTE (')?
> I HAVE A COL IN A TB THAT CONTAINS DATA SUCH AS DE'ANGLIO
> AND SMITH'S.  I NEED TO LOCATE THESE RECORDS WITH SINGLE
> QUOTES IN THEM.
> THANK
> JEFF

 
 
 

SELECT SINGLE QUOTE STATEMENT?

Post by John Madiso » Thu, 15 Aug 2002 00:24:42


This will find single quotes:
SELECT FIELDNAME FROM TABLE WHERE FIELDNAME LIKE '%' + CHAR
(39) + '%'

If you don't have an ASCII table handy, run the following
script:




BEGIN



END

Quote:>-----Original Message-----
>HOW DO I WRITE A SELECT STATEMENT THAT SEARCHES FOR A
>SINGLE QUOTE (')?
>I HAVE A COL IN A TB THAT CONTAINS DATA SUCH AS DE'ANGLIO
>AND SMITH'S.  I NEED TO LOCATE THESE RECORDS WITH SINGLE
>QUOTES IN THEM.
>THANK
>JEFF
>.

 
 
 

SELECT SINGLE QUOTE STATEMENT?

Post by Tony Rizz » Thu, 15 Aug 2002 00:27:29


try:

select *
from table
where column like '%''%'

-- double the single quote to 'escape' it

Tony


Quote:> HOW DO I WRITE A SELECT STATEMENT THAT SEARCHES FOR A
> SINGLE QUOTE (')?
> I HAVE A COL IN A TB THAT CONTAINS DATA SUCH AS DE'ANGLIO
> AND SMITH'S.  I NEED TO LOCATE THESE RECORDS WITH SINGLE
> QUOTES IN THEM.
> THANK
> JEFF