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
 replacing a letter

Author  Topic 

ahmeds08
Aged Yak Warrior

737 Posts

Posted - 2010-11-22 : 01:57:29
hello everybody,
could anybody explain me how to replace a particular letter in sql server using query.
for example:i have a word 'smith' in a table.now i want the letter 'i' to replaced with letter 'e'.
thanx in advance

Devart
Posting Yak Master

102 Posts

Posted - 2010-11-22 : 02:15:52
Hello,

For example:

update <your_table_name>
set <your_field_name>=replace(<your_field_name>,'i','e')
where <your_field_name>='smith'

or

update <your_table_name>
set <your_field_name>=replace(<your_field_name>,'smith','smeth')

Best regards,

Devart,
SQL Server Tools:
dbForge Schema Compare
dbForge Data Compare
dbForge Query Builder
Go to Top of Page

ahmeds08
Aged Yak Warrior

737 Posts

Posted - 2010-11-22 : 07:44:12
thanx buddy..is it the same while performing select operation also?
Go to Top of Page

GilaMonster
Master Smack Fu Yak Hacker

4507 Posts

Posted - 2010-11-22 : 07:59:12
The use of REPLACE is the same.

--
Gail Shaw
SQL Server MVP
Go to Top of Page

ahmeds08
Aged Yak Warrior

737 Posts

Posted - 2010-11-22 : 08:19:13
thanx shaw
Go to Top of Page
   

- Advertisement -