如何用sql把 <p>test</p>,<p>test2</p>  变成 test,test2(也就是把<p>和</p>去掉)

解决方案 »

  1.   

    这样最简单
    replace(replace('<p>test</p>,<p>test2</p>','<p>',''),'</p>','')
      

  2.   

    select replace(replace('<p>test</p>,<p>test2</p>','<p>',''),'</p>','')/*                                                                                                                                                                                                                                                                 
    ----------------
    test,test2*/
      

  3.   

    http://msdn.microsoft.com/zh-cn/magazine/cc163473.aspx
    存储过程调用 clr 程序集去处理,
      

  4.   

    如果<p>test</p>,<p>test2</p>是ntext类型的,用replace是不是也可以???
      

  5.   


    select replace(replace('<p>test</p>','<p>',''),'</p>','')
    select replace(replace('<p>test2</p>','<p>',''),'</p>','')
      

  6.   

    select replace(replace('<p>test</p>,<p>test2</p>','<p>',''),'</p>','')
      

  7.   


    DECLARE @a TABLE
    (
        col     NTEXT
    )INSERT INTO @a VALUES('<p>test</p>')select replace(replace(CAST(col AS VARCHAR(max)),'<p>',''),'</p>','') FROM @a
      

  8.   


    if OBJECT_ID('tempdb..#') is not null
     drop table #;
    go
    create table # (x ntext);
    go
    insert into # values('<p>test1</p>,<p>test2</p>');
    go
    select cast(x as xml).value('for $p in /. return data($p)','nvarchar(max)') from #;
    /*
    test1,test2
    */