[Microsoft][ODBC SQL Server Driver][SQl Server]参数数据类型 text 对于 replace 函数的参数 1 无效。...
說到數(shù)據(jù)庫中文本的替換,一般人首先想到的是Replace函數(shù):
update Table set Column=Replace(Column,’oldkeyword’,'newkeyword’)
不過,當(dāng)Column為text或ntext時(shí),用以上的查詢就會(huì)報(bào)錯(cuò)“參數(shù)數(shù)據(jù)類型 text 對(duì)于 replace 函數(shù)的參數(shù) 1 無效”。原來問題是出在對(duì)text或ntext類型的數(shù)據(jù)在查詢中不能進(jìn)行字符串操作。這時(shí)用得最多的便是把text當(dāng)作varchar(實(shí)際內(nèi)容長度低于8000字節(jié)時(shí))或把ntext當(dāng)作nvarchar(實(shí)際內(nèi)容長度低于4000字節(jié)時(shí))來處理了:
update Table set Column=Replace(Cast(Column as varchar(8000)),’oldkeyword’,'newkeyword’)
update Table set Column=Replace(Cast(Column as nvarchar(4000)),’oldkeyword’,'newkeyword’)
轉(zhuǎn)載于:https://www.cnblogs.com/mssql/archive/2011/01/22/tt37.html
總結(jié)
以上是生活随笔為你收集整理的[Microsoft][ODBC SQL Server Driver][SQl Server]参数数据类型 text 对于 replace 函数的参数 1 无效。...的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: AIR配置文件详解
- 下一篇: HDU 2087剪花布条 KMP