我有一个名为 URLLocation 的字段,其中包含 URL,即 http://intranet.prodi.com。我想从所有记录和数据库中找到“Intranet”一词,并用 spdata 替换。所以 URL 将是 http://spdata.prodi.com
到目前为止我有以下 SQL 脚本
update tblRecord
set URLLocation = SUBSTRING(URLLocation , 0, CHARINDEX('&intranet=',URLLocation))
where URLLocation like '%intranet%'
我希望你能凭借知识的运气来玩子字符串,因为你的请求和你写的内容有不同的含义。假设您需要替换 URI 中的单词
update tblRecord
set URLLocation = REPLACE(URLLocation, 'intranet.', 'spdata.')
where URLLocation like '%intranet.%'