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 2005 Forums
 Transact-SQL (2005)
 Search Field for a specific character

Author  Topic 

HGClubTec
Starting Member

12 Posts

Posted - 2010-04-23 : 09:48:16
I need to search a character field (in this case - a name) for a " and if it contains a quote then I need to add quotes to the beginning and end of the field. Is this possible?

As an example...

If I have Jennifer "Jen" then I need it to return "Jennifer "Jen""

TIA!

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-04-23 : 09:50:53
SELECT CASE WHEN CHARINDEX('"',field) > 0 THEN '"' + field + '"' ELSE field END FROM Table

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

Go to Top of Page

HGClubTec
Starting Member

12 Posts

Posted - 2010-04-23 : 10:11:51
Awesome!! THANKS!!!!
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-04-23 : 10:12:51
welcome

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

Go to Top of Page
   

- Advertisement -