October 13, 2005 at 1:23 pm
This is I need, thanks Ray.
One more question please, how update single characters in begin of string ?
Ex: "M Carlos"
Result:
"Mh Carlos"
Thanks a lot
-- This update will get single characters in middle of string
update mytable
set myColumn = Stuff(@String, Patindex('% [A-Z] %', @String ) +2, 1, 'h ')
where Patindex('% [A-Z] %', myColumn ) > 0
-- This update will get single characters at the end of string
update mytable
set myColumn = myColumn + 'H'
where Patindex('% [A-Z]', myColumn ) > 0
October 13, 2005 at 2:12 pm
Example
declare @String varchar(100)
set @String = 'M Carlos'
select Stuff(@String, Patindex('[A-Z] %', @String ) +1, 1, 'h ')
Result
'Mh Carlos'
OOPS EDITED:
update mytable
set myColumn = Stuff(@String, Patindex('[A-Z] %', myColumn) +1, 1, 'h ')
where Patindex('[A-Z] %', myColumn) > 0
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply