<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://dotnetslackers.com/Community/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Bashar Kokash' Blog : C#, T-SQL</title><link>http://dotnetslackers.com/Community/blogs/basharkokash/archive/tags/C_2300_/T-SQL/default.aspx</link><description>Tags: C#, T-SQL</description><dc:language>en</dc:language><generator>CommunityServer 2007.1 SP1 (Build: 30415.43)</generator><item><title>Measuring SQLCR Performance using SQL Server Profiler</title><link>http://dotnetslackers.com/Community/blogs/basharkokash/archive/2008/06/09/measuring-sqlcr-performance-using-sql-server-profiler.aspx</link><pubDate>Mon, 09 Jun 2008 08:38:00 GMT</pubDate><guid isPermaLink="false">6afe0437-14b4-41d5-bc66-6d54a24dbd48:27136</guid><dc:creator>BasharKokash</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://dotnetslackers.com/Community/blogs/basharkokash/rsscomments.aspx?PostID=27136</wfw:commentRss><comments>http://dotnetslackers.com/Community/blogs/basharkokash/archive/2008/06/09/measuring-sqlcr-performance-using-sql-server-profiler.aspx#comments</comments><description>&lt;p&gt;Recently, I&amp;#39;ve been doing a lot of invoking .NET Assemblies within SQL Server 2005, I bloged an overview of SQLCLR &lt;a target="_self" href="http://dotnetslackers.com/Community/blogs/basharkokash/archive/2008/06/04/sql-clr-overview.aspx" class="null"&gt;here&lt;/a&gt;, also I posted about how to implement aggregation function in C# &lt;a target="_self" href="http://dotnetslackers.com/Community/blogs/basharkokash/archive/2008/06/07/how-to-implement-your-own-aggregate-function-in-sqlclr-sql-server-2005.aspx" class="null"&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Actually invoking .NET code has many advantages but at the same time we should be aware of the performance, that&amp;#39;s why I tested my CountNulls Aggregation function - created in a previous &lt;a target="_self" href="http://dotnetslackers.com/Community/blogs/basharkokash/archive/2008/06/07/how-to-implement-your-own-aggregate-function-in-sqlclr-sql-server-2005.aspx" class="null"&gt;post&lt;/a&gt; - with the SQL Server Profiler tool.&lt;/p&gt;
&lt;p&gt;I tested the function on the Person.Contact table that is in the AdventureWorks Database which contains 19972 records.&lt;/p&gt;
&lt;p&gt;SELECT dbo.CountNulls(MiddleName)&amp;nbsp; from Person.Contact&lt;/p&gt;
&lt;p&gt;The duration time was ranging between 93 and 154 milliseconds&lt;/p&gt;
&lt;p&gt;While the following T-SQL&amp;nbsp;statement&amp;nbsp;gives the same results but&amp;nbsp;with duration time&amp;nbsp;ranges from 1 to 3 milliseconds maximum.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Select count(*) as from Person.Contact where MiddleName is null&lt;/p&gt;
&lt;p&gt;As a result we should not move to use SQLCLR unless there is a clear sign, that means to implement a function in .NET we have to give T-SQL a chance and only when T-SQL fails we then use .NET Assemblies.&lt;/p&gt;&lt;img src="http://dotnetslackers.com/Community/aggbug.aspx?PostID=27136" width="1" height="1"&gt;</description><category domain="http://dotnetslackers.com/Community/blogs/basharkokash/archive/tags/C_2300_/default.aspx">C#</category><category domain="http://dotnetslackers.com/Community/blogs/basharkokash/archive/tags/SQL+SERVER+2005/default.aspx">SQL SERVER 2005</category><category domain="http://dotnetslackers.com/Community/blogs/basharkokash/archive/tags/SQL+CLR/default.aspx">SQL CLR</category><category domain="http://dotnetslackers.com/Community/blogs/basharkokash/archive/tags/Performance/default.aspx">Performance</category><category domain="http://dotnetslackers.com/Community/blogs/basharkokash/archive/tags/T-SQL/default.aspx">T-SQL</category></item></channel></rss>