<?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"
	>
<channel>
	<title>Comments on: Off-Topic: T-SQL: Replace all occurrences in all columns in all tables?</title>
	<atom:link href="http://alexduggleby.com/2008/05/09/off-topic-t-sql-replace-all-occurrences-in-all-columns-in-all-tables/feed/" rel="self" type="application/rss+xml" />
	<link>http://alexduggleby.com/2008/05/09/off-topic-t-sql-replace-all-occurrences-in-all-columns-in-all-tables/</link>
	<description>Just me, you and a cup of tee...</description>
	<pubDate>Sun, 20 Jul 2008 00:21:59 +0000</pubDate>
	<generator>http://wordpress.org/?v=MU</generator>
		<item>
		<title>By: Anja</title>
		<link>http://alexduggleby.com/2008/05/09/off-topic-t-sql-replace-all-occurrences-in-all-columns-in-all-tables/#comment-959</link>
		<dc:creator>Anja</dc:creator>
		<pubDate>Sun, 06 Jul 2008 21:05:58 +0000</pubDate>
		<guid isPermaLink="false">http://alexduggleby.wordpress.com/?p=107#comment-959</guid>
		<description>Hi Alex,
Just wanted to thank you for posting your SQL code. Our database was injected with malicious scripts and your code helped me clean up hundreds of thousands of records. 

You saved my day! :)
Anja</description>
		<content:encoded><![CDATA[<p>Hi Alex,<br />
Just wanted to thank you for posting your SQL code. Our database was injected with malicious scripts and your code helped me clean up hundreds of thousands of records. </p>
<p>You saved my day! :)<br />
Anja</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Alex Duggleby</title>
		<link>http://alexduggleby.com/2008/05/09/off-topic-t-sql-replace-all-occurrences-in-all-columns-in-all-tables/#comment-950</link>
		<dc:creator>Alex Duggleby</dc:creator>
		<pubDate>Wed, 25 Jun 2008 12:05:24 +0000</pubDate>
		<guid isPermaLink="false">http://alexduggleby.wordpress.com/?p=107#comment-950</guid>
		<description>Hi Raj,

is it possible that the field you are using is a NTEXT or TEXT field? The script will not work on those...

(same goes for any NVARCHAR(MAX) or fields &#62; 4000 length)

Bye,
Alex</description>
		<content:encoded><![CDATA[<p>Hi Raj,</p>
<p>is it possible that the field you are using is a NTEXT or TEXT field? The script will not work on those&#8230;</p>
<p>(same goes for any NVARCHAR(MAX) or fields &gt; 4000 length)</p>
<p>Bye,<br />
Alex</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Raj</title>
		<link>http://alexduggleby.com/2008/05/09/off-topic-t-sql-replace-all-occurrences-in-all-columns-in-all-tables/#comment-949</link>
		<dc:creator>Raj</dc:creator>
		<pubDate>Wed, 25 Jun 2008 08:45:59 +0000</pubDate>
		<guid isPermaLink="false">http://alexduggleby.wordpress.com/?p=107#comment-949</guid>
		<description>Did not work for me. I was trying to replace a script tag that came in from somewhere and though I got no errors after running the script, the string I required to replace was not replaced.</description>
		<content:encoded><![CDATA[<p>Did not work for me. I was trying to replace a script tag that came in from somewhere and though I got no errors after running the script, the string I required to replace was not replaced.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Alex Duggleby</title>
		<link>http://alexduggleby.com/2008/05/09/off-topic-t-sql-replace-all-occurrences-in-all-columns-in-all-tables/#comment-938</link>
		<dc:creator>Alex Duggleby</dc:creator>
		<pubDate>Tue, 20 May 2008 12:58:38 +0000</pubDate>
		<guid isPermaLink="false">http://alexduggleby.wordpress.com/?p=107#comment-938</guid>
		<description>Hi Mike,

thanks, you are absolutely right. Must have crept into the script while making it 'bloggable' :)

The 4000 is a bit of a limit, but if I remember right I can't concat nvarchar(max) values, so I had to do it that way.

Thanks,
Alex</description>
		<content:encoded><![CDATA[<p>Hi Mike,</p>
<p>thanks, you are absolutely right. Must have crept into the script while making it &#8216;bloggable&#8217; :)</p>
<p>The 4000 is a bit of a limit, but if I remember right I can&#8217;t concat nvarchar(max) values, so I had to do it that way.</p>
<p>Thanks,<br />
Alex</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mike</title>
		<link>http://alexduggleby.com/2008/05/09/off-topic-t-sql-replace-all-occurrences-in-all-columns-in-all-tables/#comment-937</link>
		<dc:creator>Mike</dc:creator>
		<pubDate>Tue, 20 May 2008 01:04:40 +0000</pubDate>
		<guid isPermaLink="false">http://alexduggleby.wordpress.com/?p=107#comment-937</guid>
		<description>Thanks for posting the script!

I had to change line 69 to remove the quotes around the column as the first parameter to the Replace function:

SET @temp  = @temp  + ' = REPLACE(' +  @colName + ','''

Otherwise the column name would show up in the field after running the proc.

I also found out out that the output of the script for one of my tables was being truncated... probably a limitation of the NVARCHAR(4000) size.  Because I only needed to update specific columns, I was able to manually edit the script.</description>
		<content:encoded><![CDATA[<p>Thanks for posting the script!</p>
<p>I had to change line 69 to remove the quotes around the column as the first parameter to the Replace function:</p>
<p>SET @temp  = @temp  + &#8216; = REPLACE(&#8217; +  @colName + &#8216;,&#8221;&#8217;</p>
<p>Otherwise the column name would show up in the field after running the proc.</p>
<p>I also found out out that the output of the script for one of my tables was being truncated&#8230; probably a limitation of the NVARCHAR(4000) size.  Because I only needed to update specific columns, I was able to manually edit the script.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
