Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 How to search for quotes and other characters

Author  Topic 

ZLA
Starting Member

6 Posts

Posted - 2005-11-01 : 14:56:58
I have a varchar column which may contain a double quote symbol. For example, my data may look like the following:

Jim said, "Hi there."

If I try to search for this record via TSQL, I always come up empty. I've tried to use the following:

SELECT * FROM MyTable WHERE MyColumn LIKE '%"%'

That doesn't work.

Can anyone tell me the correct syntax or method to find these records?

Thanks in advance.

Seventhnight
Master Smack Fu Yak Hacker

2878 Posts

Posted - 2005-11-01 : 15:57:02
Declare @str varchar(100)
Set @str = 'Jim said, "Hi there."'

Select case when @str like '%"%' then 1 else 0 end

Corey

Co-worker on children "...when I have children, I'm going to beat them. Not because their bad, but becuase I think it would be fun ..."
Go to Top of Page

TG
Master Smack Fu Yak Hacker

6065 Posts

Posted - 2005-11-01 : 16:01:04
Your syntax works for me. does this not work on your machine?

SELECT *
FROM (select 'Jim said, "Hi there"' as myColumn) as MyTable
WHERE MyColumn LIKE '%"%'


Be One with the Optimizer
TG
Go to Top of Page

ZLA
Starting Member

6 Posts

Posted - 2005-11-01 : 16:40:39
I went back and checked and now its working. The data I thought I was looking for must not have been there when I searched for it. Thank you both.
Go to Top of Page
   

- Advertisement -