February 8, 2007 at 2:28 am
Hi,
I have a sp problem..
Regarding the problem I am giving u an example...
-A person has given the name of a project 'ABCD'.
-Now My SP saving it as:
<html>...<b>ABCD</b>...</html> in database.
-Now wanna retrieve the project name 'ABCD' only, by running a SP.
Any idea how to do that...
Thanks & Regards,
Rajdeep
February 8, 2007 at 3:11 am
Hello
If it were xml statementstored in yuor table this would be quite easy as MS SQL 2005 has XQuery language:
Suppose the '<html><a><b>ABCD</b></a></html>' is stored in the Col1 in the table Tab1. Then:
DECLARE
@xml xml
SET
@xml = SELECT Col1 FROM Tab1
DECLARE
@string varchar(20)
SET
@string = @xml.value('(/html/a/b)[1]','varchar(20)')
Then @string = 'ABCD'
Thats' all
Kindest Regards,
Damian Widera
SQL Server MVP,
MCT, MCSE Data Platform, MCSD.NET
February 8, 2007 at 6:37 am
I don't think the html tags enclosing the ABCD is same for all the rows in the column. If it is same you can just do this....
declare
@var varchar(1000)
set
@var = '<html>...<b>ABCD</b>...</html>'
SELECT
REPLACE(REPLACE(@var,'<html>...<b>',''),'</b>...</html>','') AS COL
But I know it will be dynamic and what you gave is only a example.
Prasad Bhogadi
www.inforaise.com
February 9, 2007 at 12:12 pm
Here's a function I wrote to strip HTML/XML/ASP/etc. tags out of data. It explains how to use it in your queries and exports: http://www.databasejournal.com/scripts/article.php/3494196
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply