<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: SQL User-Defined Function: ReplaceChars</title>
	<atom:link href="http://www.simonwhatley.co.uk/sql-user-defined-function-replacechars/feed" rel="self" type="application/rss+xml" />
	<link>http://www.simonwhatley.co.uk/sql-user-defined-function-replacechars</link>
	<description>The opposite of every great idea is another great idea</description>
	<lastBuildDate>Tue, 24 Jan 2012 10:54:00 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: Prasob</title>
		<link>http://www.simonwhatley.co.uk/sql-user-defined-function-replacechars/comment-page-1#comment-371</link>
		<dc:creator>Prasob</dc:creator>
		<pubDate>Thu, 25 Sep 2008 12:53:27 +0000</pubDate>
		<guid isPermaLink="false">http://www.simonwhatley.co.uk/?p=425#comment-371</guid>
		<description>By the following function we can replace with a particular word


CREATE FUNCTION dbo.udf_SubstituteChars
(
@ReplaceList		VARCHAR(50),
@String			VARCHAR(100),
@NewString              VARCHAR(50)
)
RETURNS VARCHAR(100)
AS
BEGIN
	DECLARE	@CHAR		CHAR(1),
		@Loop		INT

	SET @Loop  = 0
	WHILE @Loop &lt; = LEN(@ReplaceList)
	BEGIN
		SET	@Loop = @Loop + 1
		SET	@CHAR = SUBSTRING(@ReplaceList, @Loop, 1)
		SET	@String = REPLACE(@String, @CHAR, @NewString)
	END

	RETURN		@String

END



Then execute

select dbo.udf_SubstituteChars(&#039;a&#039;,column_name,&#039;#&#039;)
from table_name


It will replace all a&#039;s in the column_name with &#039;#&#039;s in the table</description>
		<content:encoded><![CDATA[<p>By the following function we can replace with a particular word</p>
<p>CREATE FUNCTION dbo.udf_SubstituteChars<br />
(<br />
@ReplaceList		VARCHAR(50),<br />
@String			VARCHAR(100),<br />
@NewString              VARCHAR(50)<br />
)<br />
RETURNS VARCHAR(100)<br />
AS<br />
BEGIN<br />
	DECLARE	@CHAR		CHAR(1),<br />
		@Loop		INT</p>
<p>	SET @Loop  = 0<br />
	WHILE @Loop &lt; = LEN(@ReplaceList)<br />
	BEGIN<br />
		SET	@Loop = @Loop + 1<br />
		SET	@CHAR = SUBSTRING(@ReplaceList, @Loop, 1)<br />
		SET	@String = REPLACE(@String, @CHAR, @NewString)<br />
	END</p>
<p>	RETURN		@String</p>
<p>END</p>
<p>Then execute</p>
<p>select dbo.udf_SubstituteChars(&#8216;a&#8217;,column_name,&#8217;#')<br />
from table_name</p>
<p>It will replace all a&#8217;s in the column_name with &#8216;#&#8217;s in the table</p>
]]></content:encoded>
	</item>
</channel>
</rss>

