SP Problem

  •  

    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

  • 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

  • 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

  • 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


    My blog: SQL Soldier[/url]
    SQL Server Best Practices:
    SQL Server Best Practices
    Twitter: @SQLSoldier
    My book: Pro SQL Server 2008 Mirroring[/url]
    Microsoft Certified Master: SQL Server, Data Platform MVP
    Database Engineer at BlueMountain Capital Management[/url]

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply