 




<?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>SQL Server with Mr. Denny &#187; CLR</title>
	<atom:link href="http://itknowledgeexchange.techtarget.com/sql-server/tag/clr/feed/" rel="self" type="application/rss+xml" />
	<link>http://itknowledgeexchange.techtarget.com/sql-server</link>
	<description></description>
	<lastBuildDate>Fri, 17 May 2013 17:04:01 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	
		<item>
		<title>When does SQLCLR launch?</title>
		<link>http://itknowledgeexchange.techtarget.com/sql-server/when-does-sqlclr-launch/</link>
		<comments>http://itknowledgeexchange.techtarget.com/sql-server/when-does-sqlclr-launch/#comments</comments>
		<pubDate>Thu, 14 Jun 2012 21:00:00 +0000</pubDate>
		<dc:creator>Denny Cherry</dc:creator>
				<category><![CDATA[CLR]]></category>
		<category><![CDATA[SQL CLR Procedure]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQL Server 2012]]></category>

		<guid isPermaLink="false">http://itknowledgeexchange.techtarget.com/sql-server/when-does-sqlclr-launch/</guid>
		<description><![CDATA[A change was made to the SQLCLR, as to when the SQLCLR is loaded.&#160; In SQL Server 2008 R2 and below the SQLCLR component was loaded only when the “clr enabled” setting, which is controlled through sp_configure, is enabled.&#160; Even with the SQLCLR is enabled on SQL Server 2008 R2 and below, the SQLCLR is [...]]]></description>
				<content:encoded><![CDATA[<p>A change was made to the SQLCLR, as to when the SQLCLR is loaded.&#160; In SQL Server 2008 R2 and below the SQLCLR component was loaded only when the “clr enabled” setting, which is controlled through sp_configure, is enabled.&#160; Even with the SQLCLR is enabled on SQL Server 2008 R2 and below, the SQLCLR is only loaded into SQL Server’s memory when it is needed.</p>
<p>In SQL Server 2012 however SQLCLR is loaded on startup no matter if the “clr enabled” setting is disabled or not.&#160; This can be seen in the SQL Server ERRORLOG file by looking for the line which looks similar to the following.</p>
<blockquote><p>Common language runtime (CLR) functionality initialized using CLR version v4.0.30319 from C:\Windows\Microsoft.NET\Framework64\v4.0.30319\.’</p>
</blockquote>
<p>There are a couple of reasons that Microsoft wants the SQLCLR to be loaded automatically when the SQL Server starts instead of waiting for permission to load it.</p>
<p>The first is that there are plenty of native features which require the use of the SQLCLR in SQL Server 2012.&#160; This includes features like the geometry data type, the hierarchyid data type, etc.</p>
<p>The second is that by loading the SQLCLR when the SQL Server instance first starts this decreases the time that SQL Server must wait the first time that the SQLCLR is used. This is because the SQLCLR is a rather large package which must be loaded, when loading the SQLCLR the first time it is used can take up to several seconds to load the CLR into memory for use.</p>
<p>Just because the SQLCLR is loaded into memory when the SQL Server instance is first started doesn’t mean that the sp_configure setting “clr enabled” is useless.&#160; With this setting disabled, the SQL Server instance will not allow for the creation of CLR objects.&#160; Once the “clr enabled” setting is enabled the CLR doesn’t need to be loaded, but the SQL Server instance will now allow the user created assemblies to be created within the SQL Server instance.</p>
<p>Denny</p>
<!-- wpms-network-global-inserts -->]]></content:encoded>
			<wfw:commentRss>http://itknowledgeexchange.techtarget.com/sql-server/when-does-sqlclr-launch/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>SQL Server 2012, SQLCLR and Max Server Memory</title>
		<link>http://itknowledgeexchange.techtarget.com/sql-server/sql-server-2012-sqlclr-and-max-server-memory/</link>
		<comments>http://itknowledgeexchange.techtarget.com/sql-server/sql-server-2012-sqlclr-and-max-server-memory/#comments</comments>
		<pubDate>Mon, 11 Jun 2012 21:00:00 +0000</pubDate>
		<dc:creator>Denny Cherry</dc:creator>
				<category><![CDATA[CLR]]></category>
		<category><![CDATA[SQL CLR Procedure]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQL Server 2012]]></category>

		<guid isPermaLink="false">http://itknowledgeexchange.techtarget.com/sql-server/sql-server-2012-sqlclr-and-max-server-memory/</guid>
		<description><![CDATA[When SQLCLR was first introduced in SQL Server 2005, one of the big complaints that I had with it was that SQLCLR could technically steal all the memory away from the SQL Server’s buffer pool by simply growing it’s memory pool which would cause the OS to request memory back from the SQL Server taking [...]]]></description>
				<content:encoded><![CDATA[<p>When SQLCLR was first introduced in SQL Server 2005, one of the big complaints that I had with it was that SQLCLR could technically steal all the memory away from the SQL Server’s buffer pool by simply growing it’s memory pool which would cause the OS to request memory back from the SQL Server taking memory away from the buffer pool and the execution plan cache.&#160; This could result, depending on the amount of memory that the SQLCLR needed, the entire memory for the server being eaten up by the SQLCLR component of Microsoft SQL Server, eventually possibly taking all the memory on the entire server for the SQLCLR component.</p>
<p>With the release of SQL Server 2012 this problem goes away to some extent as SQL Server 2012 had many memory architecture related changes put into the product.&#160; Among the variety of changes which were introduced in SQL Server 2012 is the fact that the SQLCLR feature now gets its memory via the traditional SQL Server memory manager.&#160; One of the side effects of this is that the SQLCLR how falls under the control of the “max server memory” setting which is accessed through the sp_configure system stored procedure.</p>
<p>While this doesn’t give you the ability to control how much memory the SQLCLR component specially will take this does mean that you can via the “max server memory” setting keep the SQLCLR processes from taking over all the memory within the Windows OS.</p>
<p>Because of this change in how memory is controlled for the SQLCLR component when upgrading from a prior version of Microsoft SQL Server to SQL Server 2012&#160; the value which is used for the “max server memory” setting will need to be re-thought out as we no longer need to leave room outside the setting for the SQLCLR.&#160; As an example, if a Windows Server with a single instance of Microsoft SQL Server 2008 had 64 Gigs of RAM installed and the instance was a heavy user of SQLCLR it might have made sense to configure the SQL Server instance with 50 Gigs of memory as the max server memory leaving about 4 Gigs for the Windows OS, and 10 Gigs for the SQLCLR.&#160; When this server is upgraded to SQL Server 2012 you would then see that the memory usage for the Windows OS would drop leaving a large amount of memory un-used as the memory which was before allocated outside of the “max server memory” setting will sit there un-used by the SQLCLR.&#160; As this memory is within the “max server memory” setting the buffer pool and procedure cache will now be reduced by the amount of memory that the SQLCLR needs to used below the 50 Gig limit, potentially reducing the amount of memory by 10 Gigs of more.</p>
<p>The upside to this configuration change of the way that the SQLCLR memory is managed is that if the SQLCLR only needs 1 Gig, and before it was being allocated 10 Gigs of memory (as discussed in the example above), it now only takes 1 Gig of memory.&#160; However on the down side is that there is no knob to turn to limit the amount of memory which the SQLCLR can use at the high end.</p>
<p>Denny</p>
<!-- wpms-network-global-inserts -->]]></content:encoded>
			<wfw:commentRss>http://itknowledgeexchange.techtarget.com/sql-server/sql-server-2012-sqlclr-and-max-server-memory/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Slide Decks and Sample Code from SoCal Code Camp</title>
		<link>http://itknowledgeexchange.techtarget.com/sql-server/slide-decks-and-sample-code-from-socal-code-camp/</link>
		<comments>http://itknowledgeexchange.techtarget.com/sql-server/slide-decks-and-sample-code-from-socal-code-camp/#comments</comments>
		<pubDate>Mon, 28 Jan 2008 23:56:28 +0000</pubDate>
		<dc:creator>Denny Cherry</dc:creator>
				<category><![CDATA[Beta]]></category>
		<category><![CDATA[Cache]]></category>
		<category><![CDATA[CLR]]></category>
		<category><![CDATA[Config]]></category>
		<category><![CDATA[In Person Events]]></category>
		<category><![CDATA[Query tuning]]></category>
		<category><![CDATA[Resource Governor]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[SQL Server 2005]]></category>
		<category><![CDATA[SQL Server 2008]]></category>
		<category><![CDATA[SSMS]]></category>

		<guid isPermaLink="false">http://itknowledgeexchange.techtarget.com/sql-server/slide-decks-and-sample-code-from-socal-code-camp/</guid>
		<description><![CDATA[The SoCal Code Camp was this last weekend. ... As promised here are the slide decks and sample T/SQL code from the four sessions.]]></description>
				<content:encoded><![CDATA[<p>The SoCal Code Camp was this last weekend.  I had a great time attending and speaking at the code camp this time around.   I hope that everyone who attended my sessions had as much fun attending the sessions as I did speaking at them.  I did my best to make them as much fun and interactive as I could.</p>
<p>As promised here are the slide decks and sample T/SQL code from the four sessions.  Everything is within a single ZIP file.  I&#8217;ve included two copies of each slide deck.  One in the Office 2007 format, and one in the Office 97-2003 format.  They are identical to each other, but I wanted to include both so that people with the older version of Microsoft Office can see the deck without having to download and install the patch which allows Office 2003 to view Office 2007 files.</p>
<p>The sample scripts which I&#8217;ve included are all run against the AdventureWorks database or the AdventureWorksDW database (check the USE commands at the top of the scripts).  If they need a different database they will create the new database.</p>
<p>Session 1 &#8211; <a href="http://www.mrdenny.com/downloads/SQL%20Server%20Query%20Tuning.zip" title="SQL Server 2008 Resource Governor.zip">SQL Server Query Tuning</a> (SQL 2000+)</p>
<p>Session 2 &#8211; <a href="http://www.mrdenny.com/downloads/SQL%20Server%202008%20Resource%20Governor.zip" title="SQL Server 2008 Resource Governor.zip">SQL Server 2008 Resource Governor</a> (SQL 2008 CTP5+ only)</p>
<p>Session 3 - <a href="http://www.mrdenny.com/downloads/SQL%20Server%20Service%20Broker%20in%20the%20Real%20World.zip" title="SQL Server Service Broker in the Real World.zip">SQL Server Service Broker in the Real World</a> (SQL 2005+) (I&#8217;ve fixed the problem with the single server script that we were having at the Code Camp.  Turns out I had left the route in place which is why the message never showed up.  The first script didn&#8217;t run correctly because I had run the server to server script on my virtual machine and the route was left by accident.)</p>
<p>Session 4 &#8211; <a href="http://www.mrdenny.com/downloads/SQL%20Server%202008%20What's%20on%20the%20Horizon.zip" title="SQL Server 2008 What's on the Horizon.zip">SQL Server 2008 What&#8217;s on the Horizon</a> (SQL 2008 CTP5+)</p>
<p>If you have any questions about these slide decks or sample code feel free to post a comment here, or drop me an email.</p>
<p>Denny</p>
<!-- wpms-network-global-inserts -->]]></content:encoded>
			<wfw:commentRss>http://itknowledgeexchange.techtarget.com/sql-server/slide-decks-and-sample-code-from-socal-code-camp/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>SQL CLR: The What, When, Why and How.</title>
		<link>http://itknowledgeexchange.techtarget.com/sql-server/sql-clr-the-what-when-why-and-how/</link>
		<comments>http://itknowledgeexchange.techtarget.com/sql-server/sql-clr-the-what-when-why-and-how/#comments</comments>
		<pubDate>Thu, 10 Jan 2008 08:00:58 +0000</pubDate>
		<dc:creator>Denny Cherry</dc:creator>
				<category><![CDATA[CLR]]></category>
		<category><![CDATA[Config]]></category>
		<category><![CDATA[SQL]]></category>

		<guid isPermaLink="false">http://itknowledgeexchange.techtarget.com/sql-server/sql-clr-the-what-when-why-and-how/</guid>
		<description><![CDATA[There are two camps when it comes to SQL CLR.  The DBA camp, which says don't use it, it'll kill your SQL Server and the Developer camp which says that it will save you loads of time and that you should use it for everything.]]></description>
				<content:encoded><![CDATA[<p>There are two camps when it comes to SQL CLR.  The DBA camp, which says don&#8217;t use it, it&#8217;ll kill your SQL Server and the Developer camp which says that it will save you loads of time and that you should use it for everything.  These two different camps also represent the different messages which Microsoft is giving out as well.  I highly recommend that DBAs sit in on a Microsoft developer track session and that developers sit in on a DBA track session some time.  You&#8217;ll see a wide difference in the message about CLR in the sessions.</p>
<p>SQL CLR while powerful can not save the world as we know it from T/SQL.  SQL CLR has it&#8217;s uses, and it has times when it is the wrong option.  It can most definitely not do everything.  First of all, you&#8217;ll notice that I call it SQL CLR not just CLR.  This is because only a subset of the .NET CLR is supported by SQL Server.  This subset it called the SQL CLR.  The official list of supported libraries can be found <a target="_blank" href="http://msdn2.microsoft.com/en-US/library/ms403279.aspx" title="SQL CLR List">here</a>.  If it isn&#8217;t on that list it&#8217;s not officially supported by Microsoft.  What do I mean by supported?  Well in basic terms if you are using a .NET CLR library which isn&#8217;t on that list and you start having performance issues, Microsoft can require that you remove the CLR code from the SQL Server before troubleshooting the issue.  The official support policy from Microsoft can be found in MSKB article <a target="_blank" href="http://support.microsoft.com/kb/922672/en-us" title="SQL CLR Support Article">922672</a>.</p>
<p>Now with all that said what exactly can SQL CLR functions and procedures be used for?</p>
<p>SQL CLR code is extremely powerful, and when it comes to some kinds of work can be much faster than T/SQL code.  Some examples are advanced math, string manipulation, string searching, pattern matching, etc.  Places where SQL CLR will be slower than native T/SQL will be when general data manipulation and data searching.  When writing SQL CLR functions and procedures do remember that if the .NET code has to go back to the database for any reason that data access will not be slower than doing the data access natively within T/SQL.  If nothing else you have to account for the additional time to connect to the SQL Server, check credentials and move into the correct database.  All of which takes time.  When updating records from .NET code you have to process the records one at a time.  While .NET is great at processing records row by row, SQL isn&#8217;t.  SQL will be very slow when it comes to actually processing the updates as it is optimized for record set processing not row by row processing.</p>
<p>Now that I know what I can do with it, when should I?</p>
<p>When deciding to write a .NET SQL CLR function or procedure you first need to decide; Is the SQL Server the right place to do this?  Often times the front end, or middle end (if you have an N tier application) may be a better place to do the work.  For example formatting phone numbers via a .NET function should be done on the front end, not in the database.  Encrypting a credit card number should be done in the middleware or the SQL Server (if you have a middleware layer do it there).  You probably don&#8217;t want to install the encryption method and certificate that you use to encrypt data on the end users computer.  The general rule that I like to live by is to put as much .NET code outside of the SQL Server as possible, either in the middleware or in the front end.  Now there are also times when putting the code within the SQL Server is the right place to put it.  Say that you are doing a data warehouse load and you need to parse the text of a NVARCHAR(MAX) field looking for specific key words or phrases, and if these key words or phrases exist you need to add rows somewhere else.  T/SQL may not be the best option for this.  A Full Text search will be inefficient as you will have to search the entire table every time.  A regular T/SQL LIKE command will be very slow as indexes can&#8217;t be used, and searching through large pieces of text takes SQL a lot of time.  But if you use a SQL CLR function this can be done with very little CPU time using what are called Regular Expressions.  Regular Expressions are a basic .NET function which allows you to quickly and easily search a block of text.  (Since I&#8217;m not a .NET programmer I&#8217;m not going to dive into using regular expressions, however here is an <a target="_blank" href="http://msdn.microsoft.com/msdnmag/issues/07/02/SQLRegex/default.aspx" title="Regular Expressions Article">MSDN article</a> on the topic.)</p>
<p>Other excellent uses of SQL CLR would include procedures or functions which involve advanced mathematics functions which SQL Server does not include.  These functions could be easily put into a SQL CLR procedure or function and executed within the .NET environment with the result then being used within the SQL Server.  While normally I would recommend putting this in the client tier or middle tier if the function or procedure was needed for in row processing of a query then the SQL Server may be the right place for the CLR code.</p>
<p>While the SQL CLR isn&#8217;t the end all solution that some people were looking for, and want it so desperately to be, when used correctly it can be an extremely powerful tool.  But it must be used carefully as when used incorrectly it can hamper performance of your SQL Server.</p>
<p>Denny</p>
<!-- wpms-network-global-inserts -->]]></content:encoded>
			<wfw:commentRss>http://itknowledgeexchange.techtarget.com/sql-server/sql-clr-the-what-when-why-and-how/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SQL 2008 November CTP</title>
		<link>http://itknowledgeexchange.techtarget.com/sql-server/sql-2008-november-ctp/</link>
		<comments>http://itknowledgeexchange.techtarget.com/sql-server/sql-2008-november-ctp/#comments</comments>
		<pubDate>Mon, 03 Dec 2007 08:00:43 +0000</pubDate>
		<dc:creator>Denny Cherry</dc:creator>
				<category><![CDATA[Beta]]></category>
		<category><![CDATA[CLR]]></category>
		<category><![CDATA[Installation]]></category>
		<category><![CDATA[SQL Server 2008]]></category>

		<guid isPermaLink="false">http://itknowledgeexchange.techtarget.com/sql-server/sql-2008-november-ctp/</guid>
		<description><![CDATA[We&#8217;ll I&#8217;ve finely gotten around to installing the SQL 2008 November CTP.  While walking through the installer I have seen some excellent changes.  Not only is the option to change the paths of the data files no longer hidden, there are more than just two options.  There are at least 7 paths that you get [...]]]></description>
				<content:encoded><![CDATA[<p>We&#8217;ll I&#8217;ve finely gotten around to installing the SQL 2008 November CTP.  While walking through the installer I have seen some excellent changes.  Not only is the option to change the paths of the data files no longer hidden, there are more than just two options.  There are at least 7 paths that you get to specify while installing.  The first one is the Shared component directory.  This appears to be the base path where all your binarys will be based off of.</p>
<p> Next you get the Instance root directory.  This is where the system database files will be based off of, so make sure that you don&#8217;t point this to the C drive is you want the system databases on another drive.</p>
<p>A couple of screens later you get to set 6 install paths.  The first is the data root directory.  This changes the base path for all the others options.  The others are the User database folder, user log database folder, tempdb data folder, tempdb log folder, and the backup directory.</p>
<p>This amount of flexability in the installer is a first, and it&#8217;s a welcome change.  Look for more posts, tips and articles about SQL Server 2008 in the comming weeks and months up till the release.</p>
<p>Denny</p>
<!-- wpms-network-global-inserts -->]]></content:encoded>
			<wfw:commentRss>http://itknowledgeexchange.techtarget.com/sql-server/sql-2008-november-ctp/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
