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
 General SQL Server Forums
 New to SQL Server Programming
 Finding a chararcter

Author  Topic 

roger00713
Starting Member

11 Posts

Posted - 2010-02-10 : 20:32:22
Hi. I am wondering if someone can please point me in the right direction.
I am wanting to search for any apostrophes that turns up in a certain field. It is a surname field. An example would be O'Reily.
I am struggling with the fact that SQL recognizes the Apostrophe as the end of my statement.
Any help would be much appreciated.
Thanks.

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-02-11 : 00:10:19
[code]SELECT * FROM YourTable WHERE CHARINDEX('''',Youfield)>0[/code]

will return you field values containing apostrophes

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-02-11 : 00:14:55
Also see

http://sqlblogcasts.com/blogs/madhivanan/archive/2008/02/19/understanding-single-quotes.aspx

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

roger00713
Starting Member

11 Posts

Posted - 2010-02-11 : 17:33:44
Thanks for your help with this.
Your suggestion worked perfectly.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-02-12 : 01:11:41
welcome

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2010-02-12 : 01:33:14
or

SELECT * FROM YourTable WHERE Youfield like '%''%'

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -