Showing posts with label dbo. Show all posts
Showing posts with label dbo. Show all posts

Monday, March 26, 2012

REPLACE statement

I am running the following statement but its not updating anything. Whats
wrong.
update baandb.dbo.ttiitm012500
set t_item = REPLACE(t_item,'- get fro','')
where t_item like '%get fro%'
Message posted via droptable.com
http://www.droptable.com/Uwe/Forums.aspx/sql-server/200701/1
ok I found my stupid error. a space in the wrong place.
ghunter wrote:
>I am running the following statement but its not updating anything. Whats
>wrong.
>update baandb.dbo.ttiitm012500
>set t_item = REPLACE(t_item,'- get fro','')
>where t_item like '%get fro%'
Message posted via droptable.com
http://www.droptable.com/Uwe/Forums.aspx/sql-server/200701/1

REPLACE statement

I am running the following statement but its not updating anything. Whats
wrong.
update baandb.dbo.ttiitm012500
set t_item = REPLACE(t_item,'- get fro','')
where t_item like '%get fro%'
Message posted via droptable.com
http://www.droptable.com/Uwe/Forum...server/200701/1ok I found my stupid error. a space in the wrong place.
ghunter wrote:
>I am running the following statement but its not updating anything. Whats
>wrong.
>update baandb.dbo.ttiitm012500
>set t_item = REPLACE(t_item,'- get fro','')
>where t_item like '%get fro%'
Message posted via droptable.com
http://www.droptable.com/Uwe/Forum...server/200701/1

REPLACE statement

I am running the following statement but its not updating anything. Whats
wrong.
update baandb.dbo.ttiitm012500
set t_item = REPLACE(t_item,'- get fro','')
where t_item like '%get fro%'
--
Message posted via SQLMonster.com
http://www.sqlmonster.com/Uwe/Forums.aspx/sql-server/200701/1ok I found my stupid error. a space in the wrong place.
ghunter wrote:
>I am running the following statement but its not updating anything. Whats
>wrong.
>update baandb.dbo.ttiitm012500
>set t_item = REPLACE(t_item,'- get fro','')
>where t_item like '%get fro%'
--
Message posted via SQLMonster.com
http://www.sqlmonster.com/Uwe/Forums.aspx/sql-server/200701/1

Wednesday, March 21, 2012

Replace data portion of a column

Hi all. I have a table, with information that complies with a condition
similar to this:
Select
*
From dbo.Object
Where
Name Like '%triplle%'
And I need to replace, for all those rows, in the column [Name], the word
'Triplle' with 'Triple', and leave the rest of the characters in [Name],
intact.
For example:
'This is an example triplle' convert to 'This is an example triple'
'Another triplle here' convert to 'Another triple here'
'and triplle here also' convert to 'and triple here also'
Problem is, that [Name] is of type NText, and Replace doesn't work with
NText. So far, I'm using this, which would be a problem, if the text
contained in [Name], is greater than 3000 (or any other number that I use):
Update dbo.Object
Set
Name = Replace( Convert( NChar( 3000 ), Valor ), 'triplle', 'triple' )
Where
Name Like '%triplle%'
I came up with another solution, which looks too complicated (but it works),
by using TextPtr, CharIndex, UpDateText. I have the idea that there should
be a simpler and better solution. Is there such?
Appreciate your help,
FrankCREATE TABLE testb ([name] ntext)
INSERT INTO testb VALUES ('This is an example triplle')
INSERT INTO testb VALUES ('Another triplle here')
INSERT INTO testb VALUES ('and triplle here also')
select substring([name], 0, PATINDEX('%triplle%',[name])) + 'triple' +
substring([name], PATINDEX('%triplle%',[name]) + 7,DATALENGTH([name]))
from testb
This will work if the word 'triplle' occurs only once for each value of the
ntext column. If it could appear multiple times, then encapsulate the above
within a WHILE loop to remove all occurrences.
--
If you posted to this forum through TechNet, and you found my answers
helpful, please mark them as answers.
"John Francisco Williams" wrote:

> Hi all. I have a table, with information that complies with a condition
> similar to this:
> Select
> *
> From dbo.Object
> Where
> Name Like '%triplle%'
> And I need to replace, for all those rows, in the column [Name], the word
> 'Triplle' with 'Triple', and leave the rest of the characters in [Name],
> intact.
> For example:
> 'This is an example triplle' convert to 'This is an example triple'
> 'Another triplle here' convert to 'Another triple here'
> 'and triplle here also' convert to 'and triple here also'
> Problem is, that [Name] is of type NText, and Replace doesn't work with
> NText. So far, I'm using this, which would be a problem, if the text
> contained in [Name], is greater than 3000 (or any other number that I use):
> Update dbo.Object
> Set
> Name = Replace( Convert( NChar( 3000 ), Valor ), 'triplle', 'triple'
)
> Where
> Name Like '%triplle%'
> I came up with another solution, which looks too complicated (but it works
),
> by using TextPtr, CharIndex, UpDateText. I have the idea that there should
> be a simpler and better solution. Is there such?
> Appreciate your help,
> Frank
>
>