Hi,
I have a column in SQL DB and the column contains the information like:
<ProductDescription>This TV is good. </ProductDescription> This TV is sold
out.
<ProductDescription>This TV is bad. </ProductDescription> This TV is not
selling well.
(By the way, I am NOT talking about the XML-formatted SQL DB, which was
introduced in SQL 2000. The tag is just text mainly used for human
consumption.)
I want to delete all the text between <ProductDescription> and
</ProductDescription>, including the tags from the column. Is it possible?
It looks like the Replace function cannot take wildcard character and I am
thinking doing it programmatically, like with C#, is the only way. I
appreciate your help!Try something like this:
declare @.tag varchar(30)
declare @.test varchar(8000)
set @.test = 'Don''t get <tag> get rid of this </tag>rid of outside stuff'
set @.tag = 'tag'
select
stuff(@.test,charindex('<'+@.tag+'>',@.test),charindex('</'+@.tag+'>',@.test) +
len(@.tag) + 2,'')
----
Louis Davidson - http://spaces.msn.com/members/drsql/
SQL Server MVP
"Kevin" <no_spam@.nospamfordiscussion.com> wrote in message
news:OfqSCkMYFHA.1736@.tk2msftngp13.phx.gbl...
> Hi,
> I have a column in SQL DB and the column contains the information like:
> <ProductDescription>This TV is good. </ProductDescription> This TV is sold
> out.
> <ProductDescription>This TV is bad. </ProductDescription> This TV is not
> selling well.
> (By the way, I am NOT talking about the XML-formatted SQL DB, which was
> introduced in SQL 2000. The tag is just text mainly used for human
> consumption.)
> I want to delete all the text between <ProductDescription> and
> </ProductDescription>, including the tags from the column. Is it possible?
> It looks like the Replace function cannot take wildcard character and I am
> thinking doing it programmatically, like with C#, is the only way. I
> appreciate your help!
>
>|||Thanks! Didn't think of using that function.
"Louis Davidson" <dr_dontspamme_sql@.hotmail.com> wrote in message
news:%23o1nh9MYFHA.2588@.TK2MSFTNGP14.phx.gbl...
> Try something like this:
> declare @.tag varchar(30)
> declare @.test varchar(8000)
> set @.test = 'Don''t get <tag> get rid of this </tag>rid of outside stuff'
> set @.tag = 'tag'
> select
> stuff(@.test,charindex('<'+@.tag+'>',@.test),charindex('</'+@.tag+'>',@.test) +
> len(@.tag) + 2,'')
> --
> ----
--
> Louis Davidson - http://spaces.msn.com/members/drsql/
> SQL Server MVP
>
> "Kevin" <no_spam@.nospamfordiscussion.com> wrote in message
> news:OfqSCkMYFHA.1736@.tk2msftngp13.phx.gbl...
>
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment