在数据库中搜索并替换部分字符串 [英] Search and replace part of string in database

查看:28
本文介绍了在数据库中搜索并替换部分字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要替换以 nvarchar 形式存储在我的数据库中的所有 iframe 标记.我可以使用以下 sql 问题找到条目:

I need to replace all iframe tags, stored as nvarchar in my database. I can find the entries using the following sql-question:

SELECT * FROM databasename..VersionedFields WHERE Value LIKE '%<iframe%'

说我要替换下面的代码段:

Say I want to replace the following code segment:

code before iframe <iframe src="yadayada"> </iframe> code after iframe

有了这个:

code before iframe <a>iframe src="yadayada"</a> code after iframe

推荐答案

我认为应该执行 2 个更新调用

I think 2 update calls should do

update VersionedFields
set Value = replace(value,'<iframe','<a><iframe')

update VersionedFields
set Value = replace(value,'> </iframe>','</a>')

这篇关于在数据库中搜索并替换部分字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆