如何查询字段中的%,如何替换%全角的百分号

解决方案 »

  1.   

    update tb set col=replace(col,'%','%')
      

  2.   


    --如何查询字段中的%
    Create Table TEST
    (ID Int,
    Name Varchar(100))
    Insert TEST Select 1, '2%3'
    Union All Select 2, '%23'
    Union All Select 2, '23'
    GO
    Select * From TEST Where Name Like '%[%]%'
    GO
    Drop Table TEST
    --Result
    /*
    ID Name
    1 2%3
    2 %23
    */
      

  3.   

    --如何替换%全角的百分号
    Create Table TEST
    (ID Int,
    Name Varchar(100))
    Insert TEST Select 1, '2%3'
    Union All Select 2, '%23'
    Union All Select 2, '23'
    GO
    Update TEST Set Name = Replace(Name, '%', '%')Select * From TEST
    GO
    Drop Table TEST
    --Result
    /*
    ID Name
    1 2%3
    2 %23
    2 23
    */
      

  4.   

    select * from table where charindex('%',列名)>0
    update table set 列名=replace(列名,'%','%')
      

  5.   

    --如何查询字段中的%(如果這裡的%是全角的)
    Create Table TEST
    (ID Int,
    Name Varchar(100))
    Insert TEST Select 1, '2%3'
    Union All Select 2, '%23'
    Union All Select 2, '23'
    GO
    Select * From TEST Where Name Like '%%%'
    GO
    Drop Table TEST
    --Result
    /*
    ID Name
    1 2%3
    2 %23
    */
      

  6.   


    update table set 列名=replace(列名,'%','%')
    Create Table TEST2
    (ID Int,
    Name Varchar(100))
    Insert TEST2 Select 1, '2%3'
    Union All Select 2, '%23'
    Union All Select 2, '23'
    GO
    Select * From TEST2 Where Name Like '%'+QUOTENAME ('%')+'%'
    GO
    Drop Table TEST2
      

  7.   

    update table set 列名=replace(列名,'%','%')