![]() | |||||
![]() |
|||||
|
Search and Replace in a Text Column
SQL Server has a replace function, but it doesn't work on "text" columns. SQL Server seems to address this with a new varchar(max) datatype, but those of us still using SQL Server 2000 still need a solution. The following stored procedure should do the trick. The seed of the idea for this came from the following page:
http://www.sqlteam.com/article/search-and-replace-in-a-text-column My version puts the code in a stored procedure, replaces all instances of the string, escapes any wildcard characters that might be in the string, and also prints out the number of replacements that are done. It is limited in that it won't work if the new text contains the old text, because that would cause an infinite loop, but maybe we'll be using varchar(max) before we need to do that! - David (dave@modernsignal.com) Usage: EXEC usp_utility_replacetext 'Content','htmlContent','oldtext','newtext' CREATE PROCEDURE dbo.usp_utility_ReplaceText |
June 28, 2010 -- Modern Signal launches redeveloped website for National Health Policy Forum, a nonpartisan research and public policy organization at The George Washington University. The new site includes admin tools to manage email announcements, event invitations and RSVPs, surveys, and an extensive library of publications and meeting materials. The site also features a customized Google Search integration, and a new content management system was integrated within the existing design and information architecture of the site. -View-
April 22, 2010 -- Modern Signal launches a redesigned website for The NALP Foundation for Law Career Research and Education, a nonprofit organization that works to ensure that the legal community and society at large have a reliable, objective, and affordable source of information.The site includes a content management system; bookstore; and news, events, leadership, and products tools to manage the featured homepage content. -View-
April 5, 2010 --
|
||||