表中某字段的值如下:
<pstyle="text-align:center">&nbsp;</p>
<pstyle="text-align:center">&nbsp;</p>
<pstyle="text-align:center"><a href="#branduid=13890&amp;xcode=014&amp;mcode=000&amp;scode=&amp;type=O&amp;search=&amp;sort=order"><imgalt=""src="Image/3.gif"/></a></p>
<pstyle="text-align:center">&nbsp;</p>
<pstyle="text-align:center">&nbsp;</p>
<pstyle="text-align:center">&nbsp;</p>
<p><imgalt=""src="Image/4.jpg"/></p>
<pstyle="text-align:center">面料:涤纶混纺<br/>
**********************
请问如何删除<a href=.....></a>这部分

解决方案 »

  1.   

    --> 测试数据: #tb
    if object_id('tempdb.dbo.#tb') is not null drop table #tb
    go 
    create table #tb (bz varchar(500) )
    insert into #tb
    select '<pstyle="text-align:center">&nbsp;</p>' union all 
    select '<pstyle="text-align:center">&nbsp;</p>' union all 
    select '<pstyle="text-align:center"><a href="#branduid=13890&amp;xcode=014&amp;mcode=000&amp;scode=&amp;type=O&amp;search=&amp;sort=order"><imgalt=""src="Image/3.gif"/></a></p>' union all
    select '<pstyle="text-align:center">&nbsp;</p>' union all 
    select '<pstyle="text-align:center">&nbsp;</p>' union all 
    select '<pstyle="text-align:center">&nbsp;</p>' union all 
    select '<p><imgalt=""src="Image/4.jpg"/></p>' update #tb 
    set bz=replace(bz,substring(bz,charindex('<a',bz),charindex('</a>',bz)+3-charindex('<a',bz)+1),'')
    where bz like '%'+'<a'+'%'+'</a>'+'%'select * from #tbbz
    ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    <pstyle="text-align:center">&nbsp;</p>
    <pstyle="text-align:center">&nbsp;</p>
    <pstyle="text-align:center"></p>
    <pstyle="text-align:center">&nbsp;</p>
    <pstyle="text-align:center">&nbsp;</p>
    <pstyle="text-align:center">&nbsp;</p>
    <p><imgalt=""src="Image/4.jpg"/></p>(7 行受影响)
      

  2.   

    update tb set html=stuff(html,charindex('<a',html),charindex('</a>',html)-charindex('<a',html)+4,'')
    where html like '%<a%</a>%'
      

  3.   

    这种东西最好不要用sql处理 
      

  4.   


    update tb set html=
    stuff(html,charindex('<a',html),charindex('</a>',html)-charindex('<a',html)+4,'')
    where html like '%<a%</a>%'