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 2000 Forums
 Transact-SQL (2000)
 REPLACING <section id='0'> to ''

Author  Topic 

jimmy.hunt
Starting Member

21 Posts

Posted - 2006-04-08 : 11:20:28
For some reason when I try to do this it isn't working. Any clues?

SELECT REPLACE(ArticleXML, '<section id='0'>', '') as test
from kbtable

I thought the &apos would work, but it isn't. How can I get rid of these section tags that have single quotes in them?

Thanks!
James

James Hunt

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2006-04-08 : 11:30:09
SELECT REPLACE(ArticleXML, '<section id=''0''>', '') as test
from kbtable

replace one ' with two '

Go with the flow & have fun! Else fight the flow
Blog thingie: [URL="http://weblogs.sqlteam.com/mladenp"]
Go to Top of Page

jimmy.hunt
Starting Member

21 Posts

Posted - 2006-04-08 : 12:32:32
How would I right the select statement to do this. Because neither of these work:

SELECT REPLACE(ArticleXML, '<section id='0'>', '<section id=''0''>') as test

This one gives an error:
SELECT REPLACE(ArticleXML, ''', '''') as test

James Hunt
Go to Top of Page

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2006-04-08 : 12:45:50
from where do you get ' ??

Go with the flow & have fun! Else fight the flow
Blog thingie: [URL="http://weblogs.sqlteam.com/mladenp"]
Go to Top of Page

KenW
Constraint Violating Yak Guru

391 Posts

Posted - 2006-04-08 : 13:38:40
Jimmy,

Spirit1 already gave you the answer. You need TWO single
quote characters on each side of the zero.


SELECT REPLACE(ArticleXML, '<section id=''0''>', '<section id="0">') as test


Note that the first section id has two SINGLE quotes around
the zero, whereas the second has a single DOUBLE quote on
either side of the zero.

Go to Top of Page

jimmy.hunt
Starting Member

21 Posts

Posted - 2006-04-08 : 17:02:51
OK. Great! Now I understand. Thanks!

James Hunt
Go to Top of Page
   

- Advertisement -