2016-10-10 36 views
-1

我在sql server 2012中获得了包含带链接文本的数据<a href="test/test">test </a>无目标我需要为字符串数据添加目标。我需要为此创建一个用户定义的函数。有没有人有这样的示例代码。使用UDF在字符串中为href添加目标='_ blank'的最佳方式

示例文本 -

If you've ever thought one of your text message threads was so good it deserved to be published, you may be on to something.view. <a href="/apple/sdffsd/sdffs">njkhj </a> In future iterations, users will be able to post .<br><br>You may update your email address at any time by going to <a href="/apple/fafasdf/sdfsdf">sdffsd</a>. Our whole goal is to have the reader go through an entire narrative arc in five minutes and consume it in a way that's native to mobile," says Gupta go to <a href="https://stackoverflow.com/a/s/sdfsf"> sdfsdf </a> which is one of my favorite books, is told as letters back and forth between the two main

+0

你有什么研究,尝试过,发现不起作用? SO并不是您要求量身定制的解决方案的地方,同时您也毫不费力。 – dfundako

+0

请详细说明目标'我需要添加目标' – TheGameiswar

+0

由于'target ='_ blank''在浏览器外部是无用的,您是否可以在应用程序中管理它?就像那样:http://stackoverflow.com/questions/7901679/jquery-add-target-blank-for-outgoing-link? –

回答

1

我认为一个简单的更换会做的伎俩

Declare @String varchar(max) = 'Some large text with a <a href="test/test">link</a> to content' 

Select Replace(@String,' href=','_target="blank" href=') 

返回

(No column name) 
Some large text with a <a _target="blank" href="test/test">link</a> to content 
+0

谢谢。我也是这样想的......我意识到我过于复杂,只需要简单思考。 – akki

+0

请将此标记为已回答 – akki

+0

@akki总是太容易想到事情 –

0

我们也可以使用 SELECT REPLACE(text,'<a','<a target="_blank" '); Go

相关问题