假設我有這張桌子
------- --------------------------------------------------------------------------
| id | json_text |
------- --------------------------------------------------------------------------
| aWoJl | {"color":"#1B3451","help_text":"color is here but dont replace me"} |
------- --------------------------------------------------------------------------
| r5Njc | {"color":"#1B3451","help_text":"color is also here but dont replace me"} |
------- --------------------------------------------------------------------------
現在我想將顏色值從 更改#1B3451為#1e72d2。我怎樣才能做到這一點?
我試過使用replace(),但到目前為止沒有結果,當嘗試使用通配符時,它會拋出錯誤。
這是 SQL 小提琴。 http://sqlfiddle.com/#!18/6db3f9/1
uj5u.com熱心網友回復:
您必須先轉換為 VARCHAR 或 NVARCHAR 然后 REPLACE
UPDATE temptable set [json_text] = REPLACE(CAST([json_text] AS NVARCHAR(MAX)),N'#1B3451',N'#1e72d2');
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/525466.html
標籤:sqlsql服务器
