<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Simon Whatley &#187; function</title>
	<atom:link href="http://www.simonwhatley.co.uk/tag/function/feed" rel="self" type="application/rss+xml" />
	<link>http://www.simonwhatley.co.uk</link>
	<description>The opposite of every great idea is another great idea</description>
	<lastBuildDate>Wed, 02 Nov 2011 09:28:34 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>SQL User-Defined Function: ListToTable</title>
		<link>http://www.simonwhatley.co.uk/sql-user-defined-function-listtotable</link>
		<comments>http://www.simonwhatley.co.uk/sql-user-defined-function-listtotable#comments</comments>
		<pubDate>Mon, 22 Sep 2008 10:58:30 +0000</pubDate>
		<dc:creator>Simon</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[array]]></category>
		<category><![CDATA[data]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[database server]]></category>
		<category><![CDATA[extend]]></category>
		<category><![CDATA[function]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[sub-routine]]></category>
		<category><![CDATA[subroutine]]></category>
		<category><![CDATA[t-sql]]></category>
		<category><![CDATA[tabular]]></category>
		<category><![CDATA[UDF]]></category>
		<category><![CDATA[user defined function]]></category>

		<guid isPermaLink="false">http://www.simonwhatley.co.uk/?p=426</guid>
		<description><![CDATA[A common need in SQL is the ability to iterate over a list as if it were an array. In SQL it is not possible to declare arrays, unlike other programming languages such as ColdFusion, ActionScript and Java. Fortunately, there is a way around this problem: use a User-Defined Functions (UDFs) to create a tabular version of the data. Arrays are, after all, essentially tabular data (at their simplest, one dimension level).]]></description>
			<content:encoded><![CDATA[<p>A common need in <abbr title="Structured Query Language">SQL</abbr> is the ability to iterate over a list as if it were an <a href="http://en.wikipedia.org/wiki/Array" title="Wikipedia: Array" target="_blank" rel="nofollow">array</a>. In <abbr title="Structured Query Language">SQL</abbr> it is not possible to declare arrays, unlike other programming languages such as ColdFusion, ActionScript and Java. Fortunately, there is a way around this problem: use a <a href="http://en.wikipedia.org/wiki/User-defined_function" title="Wikipedia: User-Defined Functions" target="_blank" rel="nofollow">User-Defined Functions</a> (<abbr title="User Defined Functions">UDF</abbr>s) to create a tabular version of the data. Arrays are, after all, essentially tabular data (at their simplest, one dimension level).</p>
<p>A User-Defined Function, is a function provided by the user of a program or environment. In <abbr title="Structured Query Language">SQL</abbr> databases, a user-defined function provides a mechanism for extending the functionality of the database server by adding a function that can be evaluated in <abbr title="Structured Query Language">SQL</abbr> statements.</p>
<p><script type="text/javascript"><!--
google_ad_client = "pub-6475233631580417";
/* 468x60 Basic */
google_ad_slot = "7117418273";
google_ad_width = 468;
google_ad_height = 60;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></p>
<h3>The Function Code</h3>
<p>Below is the complete function definition:</p>

<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;"><<span style="color: #0000ff;">|</span>/1/>CREATE</span> <<span style="color: #0000ff;">|</span>/1/>FUNCTION</span> dbo.udf_ListToTable
<span style="color: #66cc66;">&#40;</span>
	@LIST 		<<span style="color: #0000ff;">|</span>/2/>NVARCHAR</span><span style="color: #66cc66;">&#40;</span><<span style="color: #0000ff;">|</span> style<span style="color: #66cc66;">=</span>"color: #cc66cc;">4000</span><span style="color: #66cc66;">&#41;</span>,
	@DELIMITER 	<<span style="color: #0000ff;">|</span>/2/>NVARCHAR</span><span style="color: #66cc66;">&#40;</span><<span style="color: #0000ff;">|</span> style<span style="color: #66cc66;">=</span>"color: #cc66cc;">10</span><span style="color: #66cc66;">&#41;</span> <span style="color: #0000ff;">=</span> <span style="color: #ff0000;">','</span>
<span style="color: #66cc66;">&#41;</span>
<<span style="color: #0000ff;">|</span>/1/>RETURNS</span> @ListTable <<span style="color: #0000ff;">|</span>/1/>TABLE</span>
<span style="color: #66cc66;">&#40;</span>
	Item <<span style="color: #0000ff;">|</span>/2/>NVARCHAR</span><span style="color: #66cc66;">&#40;</span><<span style="color: #0000ff;">|</span> style<span style="color: #66cc66;">=</span>"color: #cc66cc;">200</span><span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">&#41;</span>
<<span style="color: #0000ff;">|</span>/1/>AS</span>
<<span style="color: #0000ff;">|</span>/1/>BEGIN</span>
	<<span style="color: #0000ff;">|</span>/1/>DECLARE</span> @LenDel 	<<span style="color: #0000ff;">|</span>/2/>INT</span>
	<<span style="color: #0000ff;">|</span>/1/>DECLARE</span> @Pos 		<<span style="color: #0000ff;">|</span>/2/>INT</span>
	<<span style="color: #0000ff;">|</span>/1/>DECLARE</span> @Item 		<<span style="color: #0000ff;">|</span>/2/>NVARCHAR</span><span style="color: #66cc66;">&#40;</span><<span style="color: #0000ff;">|</span> style<span style="color: #66cc66;">=</span>"color: #cc66cc;">200</span><span style="color: #66cc66;">&#41;</span>
&nbsp;
	<span style="color: #808080;">--Get the length of the delimiter, use hack to get around LEN(' ') = 0 issue</span>
	<<span style="color: #0000ff;">|</span>/1/>SET</span> @LenDel <span style="color: #0000ff;">=</span> <span style="color: #ff00ff;">LEN</span><span style="color: #66cc66;">&#40;</span>@DELIMITER <span style="color: #0000ff;">+</span> <span style="color: #ff0000;">'|'</span><span style="color: #66cc66;">&#41;</span> <span style="color: #0000ff;">-</span> <<span style="color: #0000ff;">|</span> style<span style="color: #66cc66;">=</span>"color: #cc66cc;">1</span>
&nbsp;
	<<span style="color: #0000ff;">|</span>/1/>SET</span> @Pos <span style="color: #0000ff;">=</span> <span style="color: #ff00ff;">CHARINDEX</span><span style="color: #66cc66;">&#40;</span>@DELIMITER, @LIST<span style="color: #66cc66;">&#41;</span>
	<<span style="color: #0000ff;">|</span>/1/>WHILE</span> @Pos <span style="color: #66cc66;">&gt;</span> <<span style="color: #0000ff;">|</span> style<span style="color: #66cc66;">=</span>"color: #cc66cc;">0</span>
	<<span style="color: #0000ff;">|</span>/1/>BEGIN</span>
		<span style="color: #808080;">--Get the item</span>
		<<span style="color: #0000ff;">|</span>/1/>SET</span> @Item <span style="color: #0000ff;">=</span> <span style="color: #ff00ff;">SUBSTRING</span><span style="color: #66cc66;">&#40;</span>@LIST, <<span style="color: #0000ff;">|</span> style<span style="color: #66cc66;">=</span>"color: #cc66cc;">1</span>, @Pos-<<span style="color: #0000ff;">|</span> style<span style="color: #66cc66;">=</span>"color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span>
		<span style="color: #808080;">--Add it to the table (if not empty string)</span>
		<<span style="color: #0000ff;">|</span>/1/>IF</span> <span style="color: #ff00ff;">LEN</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff00ff;">LTRIM</span><span style="color: #66cc66;">&#40;</span>@Item<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&gt;</span> <<span style="color: #0000ff;">|</span> style<span style="color: #66cc66;">=</span>"color: #cc66cc;">0</span>
			<<span style="color: #0000ff;">|</span>/1/>INSERT</span> @ListTable <span style="color: #66cc66;">&#40;</span>Item<span style="color: #66cc66;">&#41;</span> <<span style="color: #0000ff;">|</span>/1/>VALUES</span> <span style="color: #66cc66;">&#40;</span><span style="color: #ff00ff;">LTRIM</span><span style="color: #66cc66;">&#40;</span>@Item<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
		<span style="color: #808080;">--Remove the item from the list</span>
		<<span style="color: #0000ff;">|</span>/1/>SET</span> @LIST <span style="color: #0000ff;">=</span> <span style="color: #ff00ff;">STUFF</span><span style="color: #66cc66;">&#40;</span>@LIST, <<span style="color: #0000ff;">|</span> style<span style="color: #66cc66;">=</span>"color: #cc66cc;">1</span>, @Pos+@LenDel-<<span style="color: #0000ff;">|</span> style<span style="color: #66cc66;">=</span>"color: #cc66cc;">1</span>, <span style="color: #ff0000;">''</span><span style="color: #66cc66;">&#41;</span>
		<span style="color: #808080;">--Get the position of the next delimiter</span>
		<<span style="color: #0000ff;">|</span>/1/>SET</span> @Pos <span style="color: #0000ff;">=</span> <span style="color: #ff00ff;">CHARINDEX</span><span style="color: #66cc66;">&#40;</span>@DELIMITER, @LIST<span style="color: #66cc66;">&#41;</span>
	<<span style="color: #0000ff;">|</span>/1/>END</span>
&nbsp;
	<span style="color: #808080;">--Add the last item to the table (if not empty string)</span>
	<<span style="color: #0000ff;">|</span>/1/>IF</span> <span style="color: #ff00ff;">LEN</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff00ff;">LTRIM</span><span style="color: #66cc66;">&#40;</span>@LIST<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&gt;</span> <<span style="color: #0000ff;">|</span> style<span style="color: #66cc66;">=</span>"color: #cc66cc;">0</span>
		<<span style="color: #0000ff;">|</span>/1/>INSERT</span> @ListTable <span style="color: #66cc66;">&#40;</span>Item<span style="color: #66cc66;">&#41;</span> <<span style="color: #0000ff;">|</span>/1/>VALUES</span> <span style="color: #66cc66;">&#40;</span><span style="color: #ff00ff;">LTRIM</span><span style="color: #66cc66;">&#40;</span>@LIST<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
&nbsp;
	<<span style="color: #0000ff;">|</span>/1/>RETURN</span>
<<span style="color: #0000ff;">|</span>/1/>END</span>
<<span style="color: #0000ff;">|</span>/1/>GO</span></pre></div></div>

<p>The function simply loops over the list passed into the function. Each list item is then inserted into the variable named <code>@ListTable</code>, which is of type <code>TABLE</code>. The <code>@ListTable</code> variable is then returned out of the function and can be handled the same as any other table.</p>
<p><script type="text/javascript"><!--
google_ad_client = "pub-6475233631580417";
/* 468x60 Basic */
google_ad_slot = "7117418273";
google_ad_width = 468;
google_ad_height = 60;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></p>
<h3>The Function In Use</h3>
<p>A simple demonstration is as follows:</p>

<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;"><<span style="color: #0000ff;">|</span>/1/>INSERT</span> <<span style="color: #0000ff;">|</span>/1/>INTO</span> tableName <span style="color: #66cc66;">&#40;</span>column1, column2, column3, column4<span style="color: #66cc66;">&#41;</span>
<<span style="color: #0000ff;">|</span>/1/>SELECT</span> @variable1, @variable2, myTable.item, <span style="color: #ff00ff;">GETDATE</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>
<<span style="color: #0000ff;">|</span>/1/>FROM</span> dbo.udf_ListToTable<span style="color: #66cc66;">&#40;</span>@list,<span style="color: #ff0000;">','</span><span style="color: #66cc66;">&#41;</span> <<span style="color: #0000ff;">|</span>/1/>AS</span> myTable</pre></div></div>

<p>In this example, we insert the same information (<code>@variable1</code>, <code>@variable2</code>) for every instance of an item found in <code>myTable</code>.</p>
<p>This is useful, for example, if you want to apply a setting to a group of users. The group of users could be contained in a list that needs to be parsed as a table, whilst the individual setting details are contained in the other variables.</p>
<h3>Download the Code</h3>
<p><a href="/examples/sql/functions/udf_ListToTable.txt" title="Download the code">Download the code</a>, rename the file to .sql and run on your database instance. You will then be able to reference the function in your Stored Procedures.</p>
<p><script type="text/javascript"><!--
google_ad_client = "pub-6475233631580417";
/* 468x60 Basic */
google_ad_slot = "7117418273";
google_ad_width = 468;
google_ad_height = 60;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></p>
]]></content:encoded>
			<wfw:commentRss>http://www.simonwhatley.co.uk/sql-user-defined-function-listtotable/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SQL User-Defined Function: ReplaceChars</title>
		<link>http://www.simonwhatley.co.uk/sql-user-defined-function-replacechars</link>
		<comments>http://www.simonwhatley.co.uk/sql-user-defined-function-replacechars#comments</comments>
		<pubDate>Fri, 19 Sep 2008 14:46:13 +0000</pubDate>
		<dc:creator>Simon</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[database server]]></category>
		<category><![CDATA[extend]]></category>
		<category><![CDATA[fairly straight forward]]></category>
		<category><![CDATA[function]]></category>
		<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[Oracle]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[sub-routine]]></category>
		<category><![CDATA[subroutine]]></category>
		<category><![CDATA[t-sql]]></category>
		<category><![CDATA[UDF]]></category>
		<category><![CDATA[user defined function]]></category>

		<guid isPermaLink="false">http://www.simonwhatley.co.uk/?p=425</guid>
		<description><![CDATA[The SQL Replace function enables us to look for a certain character phrase in a string and replace it with another character phrase. The updated string is then returned by the function.]]></description>
			<content:encoded><![CDATA[<p>The <abbr title="Structured Query Language">SQL</abbr> <code>REPLACE</code> function enables us to look for a certain character phrase in a string and replace it with another character phrase. The updated string is then returned by the function.</p>
<p>The syntax for this string function is the same for <abbr title="Structured Query Language">SQL</abbr> Server, Oracle and Microsoft Access. The syntax is as follows:</p>

<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;"><span style="color: #ff00ff;">REPLACE</span><span style="color: #66cc66;">&#40;</span>stringToLookIn, stringToMatch, replacementsString<span style="color: #66cc66;">&#41;</span></pre></div></div>

<p>The syntax is fairly straight forward, the <em>stringToMatch</em> parameter is the character phrase that we want to replace, the <em>replacementsString</em> is the character phrase that will replace any occurence of the stringToMatch parameter. If the stringToMatch phrase occurs more than once in the string, then all instances of the phrase will be replaced with the replacement string. If no matches were found then the string is returned unaltered.</p>
<p>If we want to match multiple items, we need to nest the <code>REPLACE</code> function:</p>

<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;"><span style="color: #ff00ff;">REPLACE</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff00ff;">REPLACE</span><span style="color: #66cc66;">&#40;</span>stringToLookIn, stringToMatch, replacementsString<span style="color: #66cc66;">&#41;</span>, stringToMatch, replacementsString<span style="color: #66cc66;">&#41;</span></pre></div></div>

<p>or set the replaced string into a new variable multiple times:</p>

<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;">stringReturned <span style="color: #0000ff;">=</span> <span style="color: #ff00ff;">REPLACE</span><span style="color: #66cc66;">&#40;</span>stringToLookIn, stringToMatch, replacementsString<span style="color: #66cc66;">&#41;</span>
stringReturned <span style="color: #0000ff;">=</span> <span style="color: #ff00ff;">REPLACE</span><span style="color: #66cc66;">&#40;</span>stringReturned, stringToMatch, replacementsString<span style="color: #66cc66;">&#41;</span></pre></div></div>

<p>This is far from ideal, especially the more strings there are to be matched. This is where <a href="http://en.wikipedia.org/wiki/User-defined_function" title="Wikipedia: User-Defined Functions" target="_blank" rel="nofollow">User-Defined Functions</a> (<abbr title="User Defined Functions">UDF</abbr>s) can provide the answer.</p>
<p>A User-Defined Function, is a function provided by the user of a program or environment. In <abbr title="Structured Query Language">SQL</abbr> databases, a user-defined function provides a mechanism for extending the functionality of the database server by adding a function that can be evaluated in <abbr title="Structured Query Language">SQL</abbr> statements.</p>
<p><script type="text/javascript"><!--
google_ad_client = "pub-6475233631580417";
/* 468x60 Basic */
google_ad_slot = "7117418273";
google_ad_width = 468;
google_ad_height = 60;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></p>
<h3>The Function Code</h3>
<p>Below is the complete function definition:</p>

<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;"><<span style="color: #0000ff;">|</span>/1/>CREATE</span> <<span style="color: #0000ff;">|</span>/1/>FUNCTION</span> dbo.udf_ReplaceChars
<span style="color: #66cc66;">&#40;</span>
@ReplaceList		<<span style="color: #0000ff;">|</span>/2/>VARCHAR</span><span style="color: #66cc66;">&#40;</span><<span style="color: #0000ff;">|</span> style<span style="color: #66cc66;">=</span>"color: #cc66cc;">50</span><span style="color: #66cc66;">&#41;</span>,
@String			<<span style="color: #0000ff;">|</span>/2/>VARCHAR</span><span style="color: #66cc66;">&#40;</span><<span style="color: #0000ff;">|</span> style<span style="color: #66cc66;">=</span>"color: #cc66cc;">100</span><span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">&#41;</span>
<<span style="color: #0000ff;">|</span>/1/>RETURNS</span> <<span style="color: #0000ff;">|</span>/2/>VARCHAR</span><span style="color: #66cc66;">&#40;</span><<span style="color: #0000ff;">|</span> style<span style="color: #66cc66;">=</span>"color: #cc66cc;">100</span><span style="color: #66cc66;">&#41;</span>
<<span style="color: #0000ff;">|</span>/1/>AS</span>
<<span style="color: #0000ff;">|</span>/1/>BEGIN</span>
	<<span style="color: #0000ff;">|</span>/1/>DECLARE</span>	@<<span style="color: #0000ff;">|</span>/2/>CHAR</span>		<<span style="color: #0000ff;">|</span>/2/>CHAR</span><span style="color: #66cc66;">&#40;</span><<span style="color: #0000ff;">|</span> style<span style="color: #66cc66;">=</span>"color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span>,
		@Loop		<<span style="color: #0000ff;">|</span>/2/>INT</span>
&nbsp;
	<<span style="color: #0000ff;">|</span>/1/>SET</span> @Loop  <span style="color: #0000ff;">=</span> <<span style="color: #0000ff;">|</span> style<span style="color: #66cc66;">=</span>"color: #cc66cc;">0</span>
	<<span style="color: #0000ff;">|</span>/1/>WHILE</span> @Loop <span style="color: #66cc66;">&lt;</span> <span style="color: #0000ff;">=</span> <span style="color: #ff00ff;">LEN</span><span style="color: #66cc66;">&#40;</span>@ReplaceList<span style="color: #66cc66;">&#41;</span>
	<<span style="color: #0000ff;">|</span>/1/>BEGIN</span>
		<<span style="color: #0000ff;">|</span>/1/>SET</span>	@Loop <span style="color: #0000ff;">=</span> @Loop <span style="color: #0000ff;">+</span> <<span style="color: #0000ff;">|</span> style<span style="color: #66cc66;">=</span>"color: #cc66cc;">1</span>
		<<span style="color: #0000ff;">|</span>/1/>SET</span>	@<<span style="color: #0000ff;">|</span>/2/>CHAR</span> <span style="color: #0000ff;">=</span> <span style="color: #ff00ff;">SUBSTRING</span><span style="color: #66cc66;">&#40;</span>@ReplaceList, @Loop, <<span style="color: #0000ff;">|</span> style<span style="color: #66cc66;">=</span>"color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span>
		<<span style="color: #0000ff;">|</span>/1/>SET</span>	@String <span style="color: #0000ff;">=</span> <span style="color: #ff00ff;">REPLACE</span><span style="color: #66cc66;">&#40;</span>@String, @<<span style="color: #0000ff;">|</span>/2/>CHAR</span>, <span style="color: #ff0000;">''</span><span style="color: #66cc66;">&#41;</span>
	<<span style="color: #0000ff;">|</span>/1/>END</span>
&nbsp;
	<<span style="color: #0000ff;">|</span>/1/>RETURN</span>		@String
&nbsp;
<<span style="color: #0000ff;">|</span>/1/>END</span>
<<span style="color: #0000ff;">|</span>/1/>GO</span></pre></div></div>

<p>The function simply loops over the replace list, finding each instance of the list item in the string in which we want to replace items. The new string is then returned out of the function.</p>
<h3>The Function In Use</h3>
<p>A very simple use of the replace function could be as follows:</p>

<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;"><<span style="color: #0000ff;">|</span>/1/>SELECT</span> dbo.udf_ReplaceChars<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'=,/,&lt;,&gt;,@,~,#'</span>, columnName<span style="color: #66cc66;">&#41;</span> <<span style="color: #0000ff;">|</span>/1/>AS</span> newColumn, columnName
<<span style="color: #0000ff;">|</span>/1/>FROM</span> tableName</pre></div></div>

<p>The function is not restricted to <code>SELECT</code> statements. Below is an example of an <code>UPDATE</code> statement utilising a variable:</p>

<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;"><<span style="color: #0000ff;">|</span>/1/>UPDATE</span> tableName
<<span style="color: #0000ff;">|</span>/1/>SET</span> columnName <span style="color: #0000ff;">=</span> dbo.udf_ReplaceChars<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'=,/,&lt;,&gt;,@,~,#'</span>, @variableName<span style="color: #66cc66;">&#41;</span>
<<span style="color: #0000ff;">|</span>/1/>WHERE</span> idName <span style="color: #0000ff;">=</span> @myId</pre></div></div>

<h3>Download the Code</h3>
<p><a href="/examples/sql/functions/udf_ReplaceChars.txt" title="Download the code">Download the code</a>, rename the file to .sql and run on your database instance. You will then be able to reference the function in your Stored Procedures.</p>
<p><script type="text/javascript"><!--
google_ad_client = "pub-6475233631580417";
/* 468x60 Basic */
google_ad_slot = "7117418273";
google_ad_width = 468;
google_ad_height = 60;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></p>
]]></content:encoded>
			<wfw:commentRss>http://www.simonwhatley.co.uk/sql-user-defined-function-replacechars/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>British Standards and Web Compliance</title>
		<link>http://www.simonwhatley.co.uk/british-standards-and-web-compliance</link>
		<comments>http://www.simonwhatley.co.uk/british-standards-and-web-compliance#comments</comments>
		<pubDate>Sat, 05 Jan 2008 20:23:49 +0000</pubDate>
		<dc:creator>Simon</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Accessibility]]></category>
		<category><![CDATA[brand]]></category>
		<category><![CDATA[British Standards]]></category>
		<category><![CDATA[British Standards Institute]]></category>
		<category><![CDATA[compliance]]></category>
		<category><![CDATA[effectiveness]]></category>
		<category><![CDATA[function]]></category>
		<category><![CDATA[Industry]]></category>
		<category><![CDATA[legal]]></category>
		<category><![CDATA[Magus Ltd]]></category>
		<category><![CDATA[online brands]]></category>
		<category><![CDATA[online performance]]></category>
		<category><![CDATA[organisational web standards]]></category>
		<category><![CDATA[PAS 124]]></category>
		<category><![CDATA[Performance]]></category>
		<category><![CDATA[Publically Accessible Standard]]></category>
		<category><![CDATA[search engine]]></category>
		<category><![CDATA[search engine optimisation]]></category>
		<category><![CDATA[SEO]]></category>
		<category><![CDATA[The Web]]></category>
		<category><![CDATA[Web]]></category>
		<category><![CDATA[web accessibility initiatives]]></category>
		<category><![CDATA[web compliance experts]]></category>
		<category><![CDATA[Web Compliance Following]]></category>
		<category><![CDATA[web presence]]></category>
		<category><![CDATA[Web Standards]]></category>
		<category><![CDATA[website]]></category>

		<guid isPermaLink="false">http://www.simonwhatley.co.uk/?p=395</guid>
		<description><![CDATA[British web compliance expert, Magus, joins forces with BSI to raise online standards.]]></description>
			<content:encoded><![CDATA[<p>Following on from the <acronym title="Royal National Institute for the Blind">RNIB</acronym>&#8216;s <a href="http://www.rnib.org.uk/xpedio/groups/public/documents/code/public_rnib008789.hcsp" title="RNIB Web Accessibility" rel="nofollow">web accessibility</a> initiatives, web compliance experts <a href="http://www.magus.co.uk" title="Magus Ltd" rel="nofollow">Magus Ltd</a> and The <a href="http://www.bsi-global.com" title="British Standards Institute" rel="nofollow">British Standards Institute</a> are working together to create a new publically accessible standard (<acronym title="Publically Accessible Standard">PAS</acronym> 124) for websites. Web standards govern the effectiveness, function and appearance of a website, and include: brand, legal, accessibility, search engine optimisation (<acronym title="Search Engine Optimisation">SEO</acronym>), usability and technical standards.</p>
<p>Websites are increasingly the key communication vehicle for a company, its brand and products.  Despite this, research from Magus shows that many of the world&#8217;s leading organisations don&#8217;t have formal brand and technical standards defined to govern their websites.  Even those that do are failing to effectively implement or enforce them, achieving full compliance with less than 20% of their own web standards.  The websites of these organisations significantly under-perform or damage the brand as a result.</p>
<p>PAS 124 will help to protect the significant investment organisations are making in their web presence and online brands, by establishing best practice for &#8220;defining, implementing and managing organisational web standards&#8221;.  It will provide a clear framework to help organisations apply standards effectively to significantly improve online performance and protect the integrity of their brands.</p>
<p>More detail can be found on the <a href="http://www.bsi-global.com/en/About-BSI/News-Room/BSI-News-Content/Disciplines/Information-Management/PAS-124/" title="BSI's press release" rel="nofollow">BSI&#8217;s press release</a>.</p>
<p><script type="text/javascript"><!--
google_ad_client = "pub-6475233631580417";
/* 468x60 Basic */
google_ad_slot = "7117418273";
google_ad_width = 468;
google_ad_height = 60;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></p>
]]></content:encoded>
			<wfw:commentRss>http://www.simonwhatley.co.uk/british-standards-and-web-compliance/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

