How can I remove leading and trailing quotes in SQL Server?

前端 未结 14 1442
青春惊慌失措
青春惊慌失措 2020-12-15 03:28

I have a table in a SQL Server database with an NTEXT column. This column may contain data that is enclosed with double quotes. When I query for this column, I want to remo

14条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-15 04:18

    You can use following query which worked for me-

    For updating-

    UPDATE table SET colName= REPLACE(LTRIM(RTRIM(REPLACE(colName, '"', ''))), '', '"') WHERE...
    

    For selecting-

    SELECT REPLACE(LTRIM(RTRIM(REPLACE(colName, '"', ''))), '', '"') FROM TableName
    

提交回复
热议问题