Site Sponsored By: SQLDSC - SQL Server Desired State Configuration
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.
Hello All,I have a string and want to replace a part of string with anotherI know this can be done with the help of replace BUTproblem is that the string that i want to replace ,exists more than once , and I want to replace only first occurance of that string.Like 'This Wolrd is a beautiful place for beautiful hearts'and I just want to replace the 1st 'beautiful' with the word 'Good'Waiting for your Kind replyThanks
visakh16
Very Important crosS Applying yaK Herder
52326 Posts
Posted - 2008-08-20 : 01:26:34
use STUFF
select stuff('This Wolrd is a beautiful place for beautiful hearts',patindex('%beautiful%','This Wolrd is a beautiful place for beautiful hearts'),len('beautiful'),'Good')
in actual case replace strings with actual field and parameter names