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

前端 未结 14 1404
青春惊慌失措
青春惊慌失措 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条回答
  • 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
    
    0 讨论(0)
  • 2020-12-15 04:19

    Try this:

    SELECT left(right(cast(SampleText as nVarchar),LEN(cast(sampleText as nVarchar))-1),LEN(cast(sampleText as nVarchar))-2)
      FROM TableName
    
    0 讨论(0)
提交回复
热议问题