查找和替换功能 [英] Find and Replace function
问题描述
我有一个叫做文章的表,在文章表中,我有'内容'叫做body。这就是内容字段名数据(类型ntext)的样子:
I have table called article and within the article table, i have 'content' called body. This is what the content fieldname data (type ntext) looks like:
<id></id><Body><p align="justify">The CMO are: CBMEZ 2006-1 E, CBMEZ 2006-1 and SMARS 2006-1 E. The price is all DNT on 17 September.</p></Body>
body标签中的数据显示了三个从表tag_library派生的名称(即CBMEZ 2006-1 E,CBMEZ 2006-1,SMARS 2006-1 E) 。
我在下面有一个函数,它查看文章表中的'content'字段名称,并匹配数据中找到的名称,以及tag_library中的名称并替换名称为超链接。
the data in the body tag, shows three names which are derived from the table tag_library (i.e. CBMEZ 2006-1 E, CBMEZ 2006-1, SMARS 2006-1 E).
I have a function below, which looks through the 'content' fieldname in article table and matches the name found in the data, with the names in tag_library and replaces the names as hyperlink.
CREATE FUNCTION dbo.ReplaceTags(@body VARCHAR(MAX))
RETURNS VARCHAR(MAX)
AS
BEGIN
SELECT @body = REPLACE(@body,name,'<a href="pagename.aspx?tag='+name+'">'+name+'</a>')
FROM Tag_Library
RETURN @body
END
但是,我想寻求帮助,我如何更改上述功能,以便找到< p align =justify>
标记,用< p align =justify> 中的超链接替换名称code>标签。
任何帮助都会非常感激。
谢谢
However, I would like to seek help, in how I can change the above function, so it finds the <p align="justify">
tag, replaces names with hyperlinks, inside the <p align="justify">
tag.
Any help would be most appreciated.
Thank you
推荐答案
查看此链接..这可能对您有所帮助..
http:// stackoverflow .com / questions / 19048705 / how-to-find-replace-space-from-hyperlink-src-attribute-sql-server [ ^ ]
See this link..This may help your problem..
http://stackoverflow.com/questions/19048705/how-to-find-replace-space-from-hyperlink-src-attribute-sql-server[^]
这篇关于查找和替换功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!