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
 SQL Server Development (2000)
 Search and replace exact word in SQL Query

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2005-08-31 : 07:35:56
sajith writes "I 've a query that should replace exact string with another string. Replace function will solve the proble partially only.


select replace('the them', 'the', 'abc') will give the result as 'abc abcm'.

I want the result as 'abc them' and not 'abc abcm'. It should replace only the exact word.


Is there any other solution other than free text index and replace function"

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-08-31 : 07:59:56
Use an extra space

select replace('the them', 'the ', 'abc ')


Madhivanan

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

DonAtWork
Master Smack Fu Yak Hacker

2167 Posts

Posted - 2005-08-31 : 10:40:47
select replace('the River Lethe is located in hell', 'the ', 'abc ')




Help us help YOU!
Read this blog entry for more details: http://weblogs.sqlteam.com/brettk/archive/2005/05/25.aspx

*need more coffee*
SELECT * FROM Users WHERE CLUE > 0
(0 row(s) affected)
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-08-31 : 10:44:50
Well. In that case split each word using split function and replace all the to abc

Madhivanan

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

- Advertisement -