October 13, 2005 at 9:43 am
People,
I need search in a string, the words that the length is 1.
Then else, make a update and plus the letter "H".
Exemplo:
"Paul Jonh e Lins"
"Ricardo A Menezes D"
----after update---
"Paul Jonh eh Lins"
"Ricardo Ah Menezes Dh"
Help please.....
thanks
October 13, 2005 at 10:07 am
I would recommend using Vladan's approach and add an
IF LEN( @parse_string) = 1
BEGIN
SET @parse_string = @parse_string + 'h'
END
(or something along those lines).
I would also recommend doing your own search and look for methods using RGR'us [Remi's] number table methods...
http://www.sqlservercentral.com/forums/shwmessage.aspx?forumid=8&messageid=224754
I wasn't born stupid - I had to study.
October 13, 2005 at 10:16 am
You'll have to do it in a couple of updates though. And you may have to create an additional update if there are single characters at the beginning of the string.
Example
declare @String varchar(100)
set @String = 'Ricardo A Menezes D'
select Stuff(@String, Patindex('% [A-Z]%', @String ) +2, 1, 'h ')
Result
'Ricardo Ah Menezes D'
declare @String varchar(100)
set @String = 'Paul Jonh e Lins'
select Stuff(@String, Patindex('% [A-Z] %', @String ) +2, 1, 'h ')
Result
'Paul Jonh eh Lins'
-- 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
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply