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)
 string manipulation

Author  Topic 

faisalpar
Starting Member

2 Posts

Posted - 2009-06-08 : 07:51:07
hello friends,
i am new to SQL.
i have a doubt regarding sql string manipulation

i have a string 'jayaram palakkad jayaraman'
i need to add XXX to word jayaram
but when i replace i am getting output like
'jayaramXXX palakkad jayaramXXXan'

but i need to add XXX only after jayaram
hw can i do that??

regards



fAiSaLsP

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2009-06-08 : 07:55:41
REPLACE(Col1 + ' ', 'jayaram', 'jayaramXXX'


E 12°55'05.63"
N 56°04'39.26"
Go to Top of Page

faisalpar
Starting Member

2 Posts

Posted - 2009-06-08 : 07:58:40
can u explain it??

fAiSaLsP
Go to Top of Page

danasegarane76
Posting Yak Master

242 Posts

Posted - 2009-06-08 : 08:13:26
As you can see the Replace Command takes three arguments
1.String to source string where the second string to be found
2.String to found
2.String to be replaced..

The above will replace all values in the COL1 which has the word jayaram to jayaramXXX
Go to Top of Page

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2009-06-08 : 08:19:55
quote:
Originally posted by Peso

REPLACE(Col1 + ' ', 'jayaram', 'jayaramXXX'


E 12°55'05.63"
N 56°04'39.26"



Shouldn't it be
REPLACE(Col1 + ' ', 'jayaram ', 'jayaramXXX ' ?



No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2009-06-08 : 08:22:02
Yes. My bad.



E 12°55'05.63"
N 56°04'39.26"
Go to Top of Page
   

- Advertisement -