如何替换SQL Server表列中的字符串

我有一个SQL Sever引用路径(UNC或其他方式)的表(),但是现在路径将更改。


在路径列中,我有很多记录,我只需要更改路径的一部分,而不是整个路径。而且我需要在每条记录中将相同的字符串更改为新的字符串。


我该如何简单update?


慕慕森
浏览 487回答 3
3回答

白衣非少年

这很简单:update my_tableset path = replace(path, 'oldstring', 'newstring')

PIPIONE

我尝试了上面的方法,但没有得到正确的结果。以下是一项:update tableset path = replace(path, 'oldstring', 'newstring') where path = 'oldstring'

婷婷同学_

UPDATE CustomReports_TaSET vchFilter = REPLACE(CAST(vchFilter AS nvarchar(max)), '\\Ingl-report\Templates', 'C:\Customer_Templates')where CAST(vchFilter AS nvarchar(max)) LIKE '%\\Ingl-report\Templates%'没有该CAST功能,我得到一个错误参数数据类型ntext对于函数的参数1无效replace。
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

SQL Server