原因:在資料查詢中replace函式無法對表table中text/ntext型別的欄位colname進行了字串操作,
解決方法:將text當作varchar(實際內容長度低于8000位元組時)或把ntext當作nvarchar(實際內容長度低于4000位元組時),
但是當text欄位內容長度超過8000或ntext欄位內容長度超過4000位元組時多出的位元組會被截斷而忽略掉,
這時我們可以使用max型別來解決這個問題,
原報錯代碼:
| 1 |
update tablename set colname=replace(colname,'oldtext','newtext');
|
修改后可執行代碼:
| 1 |
update tablename set colname=replace(Cast(colname as varchar(8000)),'oldtext','newtext');
|
| 1 |
update tablename set colname=replace(Cast(colname as nvarchar(4000)),'oldtext','newtext');
|
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/4125.html
標籤:SQL Server
上一篇:表單生成器(Form Builder)之mongodb表單資料——整理資料
下一篇:(3)SQL Server表磁區
