<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:copyright="http://blogs.law.harvard.edu/tech/rss" xmlns:image="http://purl.org/rss/1.0/modules/image/">
    <channel>
        <title>SQL Server</title>
        <link>http://weblogs.sqlteam.com/mladenp/category/223.aspx</link>
        <description>SQL Server</description>
        <language>en-US</language>
        <copyright>Mladen Prajdić</copyright>
        <managingEditor>spirit1_fe@yahoo.com</managingEditor>
        <generator>Subtext Version 1.9.4.0</generator>
        <item>
            <title>Ease your SSMS experience: SSMS Tools PACK 1.0 is out!</title>
            <link>http://weblogs.sqlteam.com/mladenp/archive/2008/05/08/Ease-your-SSMS-experience-SSMS-Tools-PACK-1.0-is-out.aspx</link>
            <description>&lt;p&gt;After a long while I've finally managed to create a release version. I've also added some cool new features.&lt;/p&gt;
&lt;p&gt;It is completely free and has no expiration date like the prior beta versions.&lt;/p&gt;
&lt;p&gt;I've also changed the RSS feed to Feedburner to which you can subscribe to at: &lt;a title="http://feeds.feedburner.com/SsmsToolsPack" href="http://feeds.feedburner.com/SsmsToolsPack"&gt;&lt;strong&gt;&lt;font color="#004080"&gt;http://feeds.feedburner.com/SsmsToolsPack&lt;/font&gt;&lt;/strong&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;If you're subscribed to the old feed please change it.&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;In &lt;a target="_blank" href="http://www.ssmstoolspack.com/"&gt;&lt;strong&gt;&lt;font color="#004080"&gt;SSMS Tools Pack 1.0&lt;/font&gt;&lt;/strong&gt;&lt;/a&gt;  you can find these features:&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;- &lt;a target="_blank" href="http://www.ssmstoolspack.com/Features.aspx#FKW"&gt;&lt;strong&gt;&lt;font color="#004080"&gt;Uppercase/Lowercase keywords&lt;/font&gt;&lt;/strong&gt;&lt;/a&gt;: &lt;/p&gt;
&lt;p&gt;          Set all keywords to uppercase or lowercase letters. Custom keywords can be added. &lt;/p&gt;
&lt;p&gt;- &lt;a target="_blank" href="http://www.ssmstoolspack.com/Features.aspx#RMS"&gt;&lt;strong&gt;&lt;font color="#004080"&gt;Run one script on multiple databases&lt;/font&gt;&lt;/strong&gt;&lt;/a&gt;: &lt;/p&gt;
&lt;p&gt;          Run selected or full window text on selected databases on the currently connected server. &lt;/p&gt;
&lt;p&gt;- &lt;a target="_blank" href="http://www.ssmstoolspack.com/Features.aspx#CEP"&gt;&lt;strong&gt;&lt;font color="#004080"&gt;Copy execution plan bitmaps to clipboard&lt;/font&gt;&lt;/strong&gt;&lt;/a&gt;: &lt;/p&gt;
&lt;p&gt;          Copy selected or all execution plans to a bitmap that is saved on the clipboard. &lt;/p&gt;
&lt;p&gt;- &lt;a target="_blank" href="http://www.ssmstoolspack.com/Features.aspx#SRE"&gt;&lt;strong&gt;&lt;font color="#004080"&gt;Search Results in Grid Mode and Execution Plans&lt;/font&gt;&lt;/strong&gt;&lt;/a&gt;: &lt;/p&gt;
&lt;p&gt;          Find all occurrences of your search string in the execution plans or in the results in datagrid mode. &lt;/p&gt;
&lt;p&gt;- &lt;a target="_blank" href="http://www.ssmstoolspack.com/Features.aspx#GIS"&gt;&lt;strong&gt;&lt;font color="#004080"&gt;Generate Insert statements for a single table, the whole database or current resultsets in grids&lt;/font&gt;&lt;/strong&gt;&lt;/a&gt;: &lt;/p&gt;
&lt;p&gt;          Generate insert statement from your data. &lt;/p&gt;
&lt;p&gt;- &lt;a target="_blank" href="http://www.ssmstoolspack.com/Features.aspx#SSC"&gt;&lt;strong&gt;&lt;font color="#004080"&gt;Query Execution History (Soft Source Control)&lt;/font&gt;&lt;/strong&gt;&lt;/a&gt;:  &lt;/p&gt;
&lt;p&gt;           Save all executed queries to file or database and easily find them. &lt;/p&gt;
&lt;p&gt;- &lt;a target="_blank" href="http://www.ssmstoolspack.com/Features.aspx#RDS"&gt;&lt;strong&gt;&lt;font color="#004080"&gt;Text document Regions and Debug sections&lt;/font&gt;&lt;/strong&gt;&lt;/a&gt;:  &lt;/p&gt;
&lt;p&gt;           Add Regions and Debug section in your scripts to ease development experience. &lt;/p&gt;
&lt;p&gt;- &lt;a target="_blank" href="http://www.ssmstoolspack.com/Features.aspx#RCS"&gt;&lt;strong&gt;&lt;font color="#004080"&gt;Running custom scripts from Object explorer's Context menu&lt;/font&gt;&lt;/strong&gt;&lt;/a&gt;:  &lt;/p&gt;
&lt;p&gt;           Speedy execution of custom scripts from Object Explorer's context menus. &lt;/p&gt;
&lt;p&gt;- &lt;a target="_blank" href="http://www.ssmstoolspack.com/Features.aspx#CRUD"&gt;&lt;strong&gt;&lt;font color="#004080"&gt;CRUD (Create, Read, Update, Delete) stored procedure generation&lt;/font&gt;&lt;/strong&gt;&lt;/a&gt;: &lt;/p&gt;
&lt;p&gt;           Generate Customizable CRUD stored procedures for all tables in your database. &lt;/p&gt;
&lt;p&gt;- &lt;a target="_blank" href="http://www.ssmstoolspack.com/Features.aspx#NQT"&gt;&lt;strong&gt;&lt;font color="#004080"&gt;New query template&lt;/font&gt;&lt;/strong&gt;&lt;/a&gt;: &lt;/p&gt;
&lt;p&gt;           Create a template that is shown when creating a new query window. &lt;/p&gt;
&lt;p&gt;  &lt;/p&gt;
&lt;p&gt;Currently supported SQL Server Management Studio versions are: &lt;/p&gt;
&lt;p&gt;&lt;a target="_blank" href="http://www.ssmstoolspack.com/Download.aspx"&gt;&lt;strong&gt;&lt;font color="#004080"&gt;SQL Server Management Studio 2008 CTP&lt;/font&gt;&lt;/strong&gt;&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;&lt;a target="_blank" href="http://www.ssmstoolspack.com/Download.aspx"&gt;&lt;strong&gt;&lt;font color="#004080"&gt;SQL Server Management Studio 2005&lt;/font&gt;&lt;/strong&gt;&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;&lt;a target="_blank" href="http://www.ssmstoolspack.com/Download.aspx"&gt;&lt;strong&gt;&lt;font color="#004080"&gt;SQL Server Management Studio 2005 Express&lt;/font&gt;&lt;/strong&gt;&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;  &lt;/p&gt;
&lt;p&gt;Hope you enjoy it! &lt;/p&gt;
&lt;p&gt;And if you're feeling extra generous there's always &lt;a target="_blank" href="http://www.ssmstoolspack.com/Download.aspx"&gt;&lt;strong&gt;&lt;font color="#004080"&gt;PayPal&lt;/font&gt;&lt;/strong&gt;&lt;/a&gt;. :) &lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;&lt;a href="http://www.dotnetkicks.com/kick/?url=http%3a%2f%2fweblogs.sqlteam.com%2fmladenp%2farchive%2f2008%2f05%2f08%2fEase-your-SSMS-experience-SSMS-Tools-PACK-1.0-is-out.aspx"&gt;&lt;img alt="kick it on DotNetKicks.com" border="0" src="http://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url=http%3a%2f%2fweblogs.sqlteam.com%2fmladenp%2farchive%2f2008%2f05%2f08%2fEase-your-SSMS-experience-SSMS-Tools-PACK-1.0-is-out.aspx" /&gt;&lt;/a&gt;  &lt;/p&gt;
&lt;table width="100%"&gt;
    &lt;tbody&gt;
        &lt;tr&gt;
            &lt;td align="left"&gt;  &lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td align="left"&gt;
            &lt;p&gt;&lt;img id="imgAdd" alt="" onload="javascript: try { SwitchToAdd(); } catch(e) {}" name="imgAdd" src="http://weblogs.sqlteam.com/images/weblogs_sqlteam_com/mladenp/225/r_OneWhitePixel.bmp" /&gt; &lt;/p&gt;
            &lt;/td&gt;
        &lt;/tr&gt;
    &lt;/tbody&gt;
&lt;/table&gt;&lt;img src="http://weblogs.sqlteam.com/mladenp/aggbug/60592.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Mladen Prajdić</dc:creator>
            <guid>http://weblogs.sqlteam.com/mladenp/archive/2008/05/08/Ease-your-SSMS-experience-SSMS-Tools-PACK-1.0-is-out.aspx</guid>
            <pubDate>Thu, 08 May 2008 08:35:14 GMT</pubDate>
            <wfw:comment>http://weblogs.sqlteam.com/mladenp/comments/60592.aspx</wfw:comment>
            <comments>http://weblogs.sqlteam.com/mladenp/archive/2008/05/08/Ease-your-SSMS-experience-SSMS-Tools-PACK-1.0-is-out.aspx#feedback</comments>
            <slash:comments>1</slash:comments>
            <wfw:commentRss>http://weblogs.sqlteam.com/mladenp/comments/commentRss/60592.aspx</wfw:commentRss>
            <trackback:ping>http://weblogs.sqlteam.com/mladenp/services/trackbacks/60592.aspx</trackback:ping>
        </item>
        <item>
            <title>SSMS Tools PACK is featured in May issue of SQL Server Magazine</title>
            <link>http://weblogs.sqlteam.com/mladenp/archive/2008/05/04/SSMS-Tools-PACK-is-featured-in-May-issue-of-SQL.aspx</link>
            <description>&lt;p&gt; &lt;/p&gt;
&lt;p&gt;Just as the title says :)&lt;/p&gt;
&lt;p&gt;You can read the article &lt;a target="_blank" href="http://www.sqlmag.com/Article/ArticleID/98307/sql_server_98307.html"&gt;&lt;strong&gt;&lt;font color="#004080"&gt;here&lt;/font&gt;&lt;/strong&gt;&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;Thanx to &lt;a target="_blank" href="http://sqlblog.com/blogs/kevin_kline/"&gt;&lt;strong&gt;&lt;font color="#004080"&gt;Kevin Kline&lt;/font&gt;&lt;/strong&gt;&lt;/a&gt; for publishing it!&lt;/p&gt;&lt;img src="http://weblogs.sqlteam.com/mladenp/aggbug/60584.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Mladen Prajdić</dc:creator>
            <guid>http://weblogs.sqlteam.com/mladenp/archive/2008/05/04/SSMS-Tools-PACK-is-featured-in-May-issue-of-SQL.aspx</guid>
            <pubDate>Sun, 04 May 2008 11:57:04 GMT</pubDate>
            <wfw:comment>http://weblogs.sqlteam.com/mladenp/comments/60584.aspx</wfw:comment>
            <comments>http://weblogs.sqlteam.com/mladenp/archive/2008/05/04/SSMS-Tools-PACK-is-featured-in-May-issue-of-SQL.aspx#feedback</comments>
            <slash:comments>4</slash:comments>
            <wfw:commentRss>http://weblogs.sqlteam.com/mladenp/comments/commentRss/60584.aspx</wfw:commentRss>
            <trackback:ping>http://weblogs.sqlteam.com/mladenp/services/trackbacks/60584.aspx</trackback:ping>
        </item>
        <item>
            <title>SQL Server 2005: Get full information about transaction locks</title>
            <link>http://weblogs.sqlteam.com/mladenp/archive/2008/04/29/SQL-Server-2005-Get-full-information-about-transaction-locks.aspx</link>
            <description>&lt;p&gt;Sometimes we wish to know what locks are being held by the transaction. Also it would be great to know what SPID owns the transaction, on which objects the locks are being held, what SQL statement caused the locks, etc...&lt;/p&gt;
&lt;p&gt;With the introduction of DMV's in SQL Server 2005 getting this information is quite easy with this query:&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;SELECT&lt;/span&gt;  L.request_session_id &lt;span class="kwrd"&gt;AS&lt;/span&gt; SPID, 
        DB_NAME(L.resource_database_id) &lt;span class="kwrd"&gt;AS&lt;/span&gt; DatabaseName,
        O.Name &lt;span class="kwrd"&gt;AS&lt;/span&gt; LockedObjectName, 
        P.object_id &lt;span class="kwrd"&gt;AS&lt;/span&gt; LockedObjectId, 
        L.resource_type &lt;span class="kwrd"&gt;AS&lt;/span&gt; LockedResource, 
        L.request_mode &lt;span class="kwrd"&gt;AS&lt;/span&gt; LockType,
        ST.text &lt;span class="kwrd"&gt;AS&lt;/span&gt; SqlStatementText,        
        ES.login_name &lt;span class="kwrd"&gt;AS&lt;/span&gt; LoginName,
        ES.host_name &lt;span class="kwrd"&gt;AS&lt;/span&gt; HostName,
        TST.is_user_transaction &lt;span class="kwrd"&gt;as&lt;/span&gt; IsUserTransaction,
        &lt;span class="kwrd"&gt;AT&lt;/span&gt;.name &lt;span class="kwrd"&gt;as&lt;/span&gt; TransactionName,
        CN.auth_scheme &lt;span class="kwrd"&gt;as&lt;/span&gt; AuthenticationMethod
&lt;span class="kwrd"&gt;FROM&lt;/span&gt;    sys.dm_tran_locks L
        &lt;span class="kwrd"&gt;JOIN&lt;/span&gt; sys.partitions P &lt;span class="kwrd"&gt;ON&lt;/span&gt; P.hobt_id = L.resource_associated_entity_id
        &lt;span class="kwrd"&gt;JOIN&lt;/span&gt; sys.objects O &lt;span class="kwrd"&gt;ON&lt;/span&gt; O.object_id = P.object_id
        &lt;span class="kwrd"&gt;JOIN&lt;/span&gt; sys.dm_exec_sessions ES &lt;span class="kwrd"&gt;ON&lt;/span&gt; ES.session_id = L.request_session_id
        &lt;span class="kwrd"&gt;JOIN&lt;/span&gt; sys.dm_tran_session_transactions TST &lt;span class="kwrd"&gt;ON&lt;/span&gt; ES.session_id = TST.session_id
        &lt;span class="kwrd"&gt;JOIN&lt;/span&gt; sys.dm_tran_active_transactions &lt;span class="kwrd"&gt;AT&lt;/span&gt; &lt;span class="kwrd"&gt;ON&lt;/span&gt; TST.transaction_id = &lt;span class="kwrd"&gt;AT&lt;/span&gt;.transaction_id
        &lt;span class="kwrd"&gt;JOIN&lt;/span&gt; sys.dm_exec_connections CN &lt;span class="kwrd"&gt;ON&lt;/span&gt; CN.session_id = ES.session_id
        &lt;span class="kwrd"&gt;CROSS&lt;/span&gt; APPLY sys.dm_exec_sql_text(CN.most_recent_sql_handle) &lt;span class="kwrd"&gt;AS&lt;/span&gt; ST
&lt;span class="kwrd"&gt;WHERE&lt;/span&gt;   resource_database_id = db_id()
&lt;span class="kwrd"&gt;ORDER&lt;/span&gt; &lt;span class="kwrd"&gt;BY&lt;/span&gt; L.request_session_id
&lt;/pre&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;Let's look at it one DMV at a time from top to bottom:&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;sys.dm_tran_locks:&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Shows us all locks held on all resources for all transaction. We start from this view since we want to get information about locked resources.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;sys.partitions: &lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Contains information about partitions in the database. We can join it to the sys.dm_tran_locks on the hobt_id &lt;font color="#ff0000"&gt;only for resource_type values 'HOBT', 'Page', 'RID'  and 'Key'&lt;/font&gt;. With this join we get the object_id of our locked table.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;sys.objects:&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Contains data for all schema scoped database objects. We join it to sys.partitions to get the Name of the locked object which is usually a table name.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;sys.dm_exec_sessions:&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Shows data about all active sessions on SQL server. We join it to sys.dm_tran_locks to get user login information for each held lock.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;sys.dm_tran_session_transactions:&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Shows data for all transactions for a session. By joining in to sys.dm_exec_sessions we get a link to all active transactions in the session.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;sys.dm_tran_active_transactions:&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Shows data for all active transactions in SQL Server. By joining it to sys.dm_tran_session_transactions we only get information for the session we want.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;sys.dm_exec_connections:&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Shows data for all connections in SQL Server. By joining it to sys.dm_exec_sessions we get connection info for our session. &lt;/p&gt;
&lt;p&gt;&lt;strong&gt;sys.dm_exec_sql_text:&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Returns SQL statement that is associated with the SQL handle input parameter. By cross applying it to the sys.dm_exec_connections we get the last executed statement for the connection, which in our case is the statement that is holding locks.&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;By applying the filter in the where clause you get the answers to questions like: &lt;/p&gt;
&lt;p&gt;- What SQL Statement is causing the lock?&lt;/p&gt;
&lt;p&gt;- Which user has executed the SQL statement that's holding the locks?&lt;/p&gt;
&lt;p&gt;- What objects/tables are being locked?&lt;/p&gt;
&lt;p&gt;- What kinds of locks are being held and on which pages, keys, RID's?&lt;/p&gt;
&lt;p&gt;- etc...&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;a href="http://www.dotnetkicks.com/kick/?url=http%3a%2f%2fweblogs.sqlteam.com%2fmladenp%2farchive%2f2008%2f04%2f29%2fSQL-Server-2005-Get-full-information-about-transaction-locks.aspx"&gt;&lt;img alt="kick it on DotNetKicks.com" border="0" src="http://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url=http%3a%2f%2fweblogs.sqlteam.com%2fmladenp%2farchive%2f2008%2f04%2f29%2fSQL-Server-2005-Get-full-information-about-transaction-locks.aspx" /&gt;&lt;/a&gt;
&lt;p&gt; &lt;/p&gt;
&lt;table width="100%"&gt;
    &lt;tbody&gt;
        &lt;tr&gt;
            &lt;td align="left"&gt;  &lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td align="left"&gt;
            &lt;p&gt;&lt;img id="imgAdd" alt="" onload="javascript: try { SwitchToAdd(); } catch(e) {}" name="imgAdd" src="http://weblogs.sqlteam.com/images/weblogs_sqlteam_com/mladenp/225/r_OneWhitePixel.bmp" /&gt; &lt;/p&gt;
            &lt;/td&gt;
        &lt;/tr&gt;
    &lt;/tbody&gt;
&lt;/table&gt;&lt;img src="http://weblogs.sqlteam.com/mladenp/aggbug/60576.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Mladen Prajdić</dc:creator>
            <guid>http://weblogs.sqlteam.com/mladenp/archive/2008/04/29/SQL-Server-2005-Get-full-information-about-transaction-locks.aspx</guid>
            <pubDate>Tue, 29 Apr 2008 18:01:31 GMT</pubDate>
            <wfw:comment>http://weblogs.sqlteam.com/mladenp/comments/60576.aspx</wfw:comment>
            <comments>http://weblogs.sqlteam.com/mladenp/archive/2008/04/29/SQL-Server-2005-Get-full-information-about-transaction-locks.aspx#feedback</comments>
            <slash:comments>10</slash:comments>
            <wfw:commentRss>http://weblogs.sqlteam.com/mladenp/comments/commentRss/60576.aspx</wfw:commentRss>
            <trackback:ping>http://weblogs.sqlteam.com/mladenp/services/trackbacks/60576.aspx</trackback:ping>
        </item>
        <item>
            <title>How SQL Server short-circuits WHERE condition evaluation</title>
            <link>http://weblogs.sqlteam.com/mladenp/archive/2008/02/25/How-SQL-Server-short-circuits-WHERE-condition-evaluation.aspx</link>
            <description>&lt;p&gt;&lt;strong&gt;It does when it feels like it, but not in the way you immediately think of&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;A few days ago &lt;a target="_blank" href="http://weblogs.sqlteam.com/jeffs"&gt;&lt;strong&gt;&lt;font color="#004080"&gt;Jeff&lt;/font&gt;&lt;/strong&gt;&lt;/a&gt; posted about &lt;a target="_blank" href="http://weblogs.sqlteam.com/jeffs/archive/2008/02/22/sql-server-short-circuit.aspx"&gt;&lt;strong&gt;&lt;font color="#004080"&gt;short-circuiting&lt;/font&gt;&lt;/strong&gt;&lt;/a&gt; wondering how it works and since I've played with this a long while ago I thought I'd share my results. Hopefully it will make it clearer how SQL Server behaves when evaluating conditions in its WHERE clause. So let's see how it's done in greater detail.&lt;/p&gt;
&lt;p&gt;First we must create our test table with some sample data which will be defined like this:&lt;/p&gt;
&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;IF&lt;/span&gt; OBJECT_ID(&lt;span class="str"&gt;'t1'&lt;/span&gt;) &lt;span class="kwrd"&gt;IS&lt;/span&gt; &lt;span class="kwrd"&gt;NOT&lt;/span&gt; &lt;span class="kwrd"&gt;NULL&lt;/span&gt;
     &lt;span class="kwrd"&gt;DROP&lt;/span&gt; &lt;span class="kwrd"&gt;TABLE&lt;/span&gt; t1

&lt;span class="kwrd"&gt;CREATE&lt;/span&gt; &lt;span class="kwrd"&gt;TABLE&lt;/span&gt; t1(id &lt;span class="kwrd"&gt;INT&lt;/span&gt; &lt;span class="kwrd"&gt;PRIMARY&lt;/span&gt; &lt;span class="kwrd"&gt;KEY&lt;/span&gt;, val &lt;span class="kwrd"&gt;VARCHAR&lt;/span&gt;(10))
&lt;span class="kwrd"&gt;INSERT&lt;/span&gt; &lt;span class="kwrd"&gt;INTO&lt;/span&gt; t1
&lt;span class="kwrd"&gt;SELECT&lt;/span&gt; 1, &lt;span class="str"&gt;'19000101'&lt;/span&gt; &lt;span class="kwrd"&gt;UNION&lt;/span&gt; &lt;span class="kwrd"&gt;ALL&lt;/span&gt; 
&lt;span class="kwrd"&gt;SELECT&lt;/span&gt; 2, &lt;span class="str"&gt;'val 2'&lt;/span&gt; &lt;span class="kwrd"&gt;UNION&lt;/span&gt; &lt;span class="kwrd"&gt;ALL&lt;/span&gt; 
&lt;span class="kwrd"&gt;SELECT&lt;/span&gt; 3, &lt;span class="str"&gt;'20080303'&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;Now let's play a bit. :)&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;/strong&gt; &lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;em&gt;AND Conditions&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Run this statement:&lt;/p&gt;
&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;SELECT&lt;/span&gt; * &lt;span class="kwrd"&gt;FROM&lt;/span&gt; t1 
&lt;span class="kwrd"&gt;WHERE&lt;/span&gt;  id / 0 = 1
       &lt;span class="kwrd"&gt;AND&lt;/span&gt; id = 2
       &lt;span class="kwrd"&gt;AND&lt;/span&gt; &lt;span class="kwrd"&gt;CONVERT&lt;/span&gt;(DATETIME, val) &amp;gt; GETDATE() &lt;/pre&gt;
&lt;p&gt;You'll get this error:&lt;/p&gt;
&lt;pre&gt;&lt;font color="#ff0000"&gt;Msg 241, Level 16, State 1, Line 10&lt;br /&gt;Conversion failed when converting datetime from character string.&lt;/font&gt;&lt;/pre&gt;
&lt;p&gt;The execution plan shows us how SQL Server parameterizes our select statement: &lt;/p&gt;
&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;SELECT&lt;/span&gt; * &lt;span class="kwrd"&gt;FROM&lt;/span&gt; [t1] &lt;span class="kwrd"&gt;WHERE&lt;/span&gt; [id]/@1=@2 &lt;span class="kwrd"&gt;AND&lt;/span&gt; [id]=@3 &lt;span class="kwrd"&gt;AND&lt;/span&gt; &lt;span class="kwrd"&gt;CONVERT&lt;/span&gt;([datetime],[val],0) &amp;gt; getdate() &lt;/pre&gt;
&lt;p&gt;The most obvious condition to fail is of course the divide by zero. You'd think it would be the first to evaluate since it's obviously an illegal call and everything else would be discarded. However because of the statement parameterization this doesn't happen because at the condition evaluation time the values 0 and 1 aren't known. For SQL Server they are still valid parameters whose condition cost must be evaluated. Going back to our error message we can see that the only row with an invalid date is the one where id = 2. This tells us that query processor first looked up the row by id, then applied the datetime conversion. Thus we get our order. Following query only strengthens our deduction since now we get the &lt;font color="#ff0000"&gt;&lt;strong&gt;"Divide by zero error encountered"&lt;/strong&gt;&lt;/font&gt;  because the date successfully converted.&lt;/p&gt;
&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;SELECT&lt;/span&gt; * &lt;span class="kwrd"&gt;FROM&lt;/span&gt; t1 
&lt;span class="kwrd"&gt;WHERE&lt;/span&gt;  id / 0 = 1
       &lt;span class="kwrd"&gt;AND&lt;/span&gt; id = 3
       &lt;span class="kwrd"&gt;AND&lt;/span&gt; &lt;span class="kwrd"&gt;CONVERT&lt;/span&gt;(DATETIME, val) &amp;gt; GETDATE() &lt;/pre&gt;
&lt;p&gt;This example shows us how SQL Server short-circuits conditions based on some internal threshold that measures condition importance and their evaluation order. There's nothing we can do about this and the order of condition evaluation when actually reading data is unknown to us. &lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;/strong&gt;  &lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;em&gt;OR Conditions&lt;/em&gt;&lt;/strong&gt; &lt;/p&gt;
&lt;p&gt;Run this statement: &lt;/p&gt;
&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;SELECT&lt;/span&gt; * &lt;span class="kwrd"&gt;FROM&lt;/span&gt; t1 
&lt;span class="kwrd"&gt;WHERE&lt;/span&gt;  id = 3
       &lt;span class="kwrd"&gt;OR&lt;/span&gt; id / 0 = 1&lt;/pre&gt;
&lt;p&gt;Here it is a whole different story than above with only AND conditions. Here you immediately see the error &lt;font color="#ff0000"&gt;&lt;strong&gt;"Divide by zero error encountered"&lt;/strong&gt;&lt;/font&gt;. If you take a closer look you'll see that we never get to the execution plan phase. Why does this differ so much from the AND conditions?  Because OR's immediately mean Table/Index scan. Therefore no parameterization is done and at the query evaluation time all of the values are known. This is when the divide by zero is caught before the execution plan is even built or taken from cache and our query fails. It doesn't matter that our first condition is already true.&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;em&gt;Literal Conditions&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Run these statements:&lt;/p&gt;
&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;SELECT&lt;/span&gt; 1 &lt;span class="kwrd"&gt;WHERE&lt;/span&gt; (1 = 1) &lt;span class="kwrd"&gt;OR&lt;/span&gt; (1 / 0 = 0)
&lt;span class="kwrd"&gt;SELECT&lt;/span&gt; 1 &lt;span class="kwrd"&gt;WHERE&lt;/span&gt; (1 = 0) &lt;span class="kwrd"&gt;OR&lt;/span&gt; (1 / 0 = 0)
&lt;/pre&gt;
&lt;p&gt;We see that with literal conditions the short circuiting is being done on 1=1 and 1=0 and the 1 / 0 isn't evaluated at all, but this is not to be mistaken to work identically with real data as is shown above.&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;em&gt;CASE Statement Conditions&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Run these 2 statements:&lt;/p&gt;
&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;SELECT&lt;/span&gt; * &lt;span class="kwrd"&gt;FROM&lt;/span&gt; t1 
&lt;span class="kwrd"&gt;WHERE&lt;/span&gt;  &lt;span class="kwrd"&gt;CASE&lt;/span&gt;
           &lt;span class="kwrd"&gt;WHEN&lt;/span&gt; ISDATE(val) = 0 &lt;span class="kwrd"&gt;THEN&lt;/span&gt; 0
           &lt;span class="kwrd"&gt;WHEN&lt;/span&gt; &lt;span class="kwrd"&gt;CONVERT&lt;/span&gt;(DATETIME, val) &amp;gt; GETDATE() &lt;span class="kwrd"&gt;THEN&lt;/span&gt; 1            
           &lt;span class="kwrd"&gt;ELSE&lt;/span&gt; 0
       &lt;span class="kwrd"&gt;END&lt;/span&gt; = 1

&lt;span class="kwrd"&gt;SELECT&lt;/span&gt; * &lt;span class="kwrd"&gt;FROM&lt;/span&gt; t1 
&lt;span class="kwrd"&gt;WHERE&lt;/span&gt;  &lt;span class="kwrd"&gt;CASE&lt;/span&gt;
           &lt;span class="kwrd"&gt;WHEN&lt;/span&gt; &lt;span class="kwrd"&gt;CONVERT&lt;/span&gt;(DATETIME, val) &amp;gt; GETDATE() &lt;span class="kwrd"&gt;THEN&lt;/span&gt; 1           
           &lt;span class="kwrd"&gt;WHEN&lt;/span&gt; ISDATE(val) = 0 &lt;span class="kwrd"&gt;THEN&lt;/span&gt; 0           
           &lt;span class="kwrd"&gt;ELSE&lt;/span&gt; 0
       &lt;span class="kwrd"&gt;END&lt;/span&gt; = 1&lt;/pre&gt;
&lt;p&gt;These 2 statements nicely illustrate that the order of condition evaluation in the CASE statement is always from first to last. The first statement will return one row since the second rows with invalid date will be filtered out by the ISDATE() function, while in the second statement it won't be filtered out and it will throw an error. This is of course quite logical because a CASE statement is simply a big if... else if... else... statement written differently.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;em&gt;&lt;/em&gt;&lt;/strong&gt; &lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;em&gt;If C++/C#/VB has short-circuiting why can't SQL Server have it?&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;To truly answer this let's take a look at how both work with conditions. C++/C#/VB all have short circuiting defined in the language specifications to speed up code execution. Why bother evaluating  N OR conditions when the first one is already true or M AND conditions when the first one is already false. &lt;/p&gt;
&lt;p&gt;We as developers have to be aware that SQL Server works differently. It is a cost based system. To get the optimal execution plan for our query the query processor has to evaluate every where condition and assign it a cost. These costs are then evaluated as a whole to form a threshold that must be lower than the defined threshold SQL Server has for a good plan. If the cost is lower than the defined threshold the plan is used, if not the whole process is repeated again with a different mix of condition costs. Cost here is either a scan or a seek or a merge join or a hash join etc... Because of this the short-circuiting as is available in C++/C#/VB simply isn't possible. You might think that forcing use of index on a column counts as short circuiting but it doesn't. It only forces the use of that index and with that shortens the list of possible execution plans. The system is still cost based.&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;As a developer you must be aware that &lt;strong&gt;SQL Server does not do short-circuiting&lt;/strong&gt; like it is done in other programming languages and &lt;strong&gt;there's nothing you can do to force it to&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;a href="http://www.dotnetkicks.com/kick/?url=http%3a%2f%2fweblogs.sqlteam.com%2fmladenp%2farchive%2f2008%2f02%2f25%2fHow-SQL-Server-short-circuits-WHERE-condition-evaluation.aspx"&gt;&lt;img alt="kick it on DotNetKicks.com" border="0" src="http://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url=http%3a%2f%2fweblogs.sqlteam.com%2fmladenp%2farchive%2f2008%2f02%2f25%2fHow-SQL-Server-short-circuits-WHERE-condition-evaluation.aspx" /&gt;&lt;/a&gt;
&lt;table width="100%"&gt;
    &lt;tbody&gt;
        &lt;tr&gt;
            &lt;td align="left"&gt;  &lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td align="left"&gt;
            &lt;p&gt;&lt;img id="imgAdd" alt="" onload="javascript: try { SwitchToAdd(); } catch(e) {}" name="imgAdd" src="http://weblogs.sqlteam.com/images/weblogs_sqlteam_com/mladenp/225/r_OneWhitePixel.bmp" /&gt; &lt;/p&gt;
            &lt;/td&gt;
        &lt;/tr&gt;
    &lt;/tbody&gt;
&lt;/table&gt;&lt;img src="http://weblogs.sqlteam.com/mladenp/aggbug/60529.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Mladen Prajdić</dc:creator>
            <guid>http://weblogs.sqlteam.com/mladenp/archive/2008/02/25/How-SQL-Server-short-circuits-WHERE-condition-evaluation.aspx</guid>
            <pubDate>Mon, 25 Feb 2008 09:54:24 GMT</pubDate>
            <wfw:comment>http://weblogs.sqlteam.com/mladenp/comments/60529.aspx</wfw:comment>
            <comments>http://weblogs.sqlteam.com/mladenp/archive/2008/02/25/How-SQL-Server-short-circuits-WHERE-condition-evaluation.aspx#feedback</comments>
            <slash:comments>6</slash:comments>
            <wfw:commentRss>http://weblogs.sqlteam.com/mladenp/comments/commentRss/60529.aspx</wfw:commentRss>
            <trackback:ping>http://weblogs.sqlteam.com/mladenp/services/trackbacks/60529.aspx</trackback:ping>
        </item>
        <item>
            <title>Integrating Profiler and PerfMon Log Files</title>
            <link>http://weblogs.sqlteam.com/mladenp/archive/2008/02/08/Integrating-Profiler-and-PerfMon-Log-Files.aspx</link>
            <description>&lt;p&gt;I've written an article here on &lt;a href="http://www.sqlteam.com"&gt;&lt;strong&gt;&lt;font color="#004080"&gt;SQL Team&lt;/font&gt;&lt;/strong&gt;&lt;/a&gt; about Integrating Profiler and PerfMon Log Files.&lt;/p&gt;
&lt;p&gt;Troubleshooting SQL Server requires the use of both PerfMon (Performance/System Monitor) and SQL Trace files created by SQL Profiler or directly by SQL Server trace. Analysis of the gathered data is much easier if you can correlate your trace file with the PerfMon counters. In this article I'll show how to create a PerfMon counters log file and SQL Profiler Trace file, how to read them both and how to correlate the two files in SQL Profiler.&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;&lt;a target="_blank" href="http://www.sqlteam.com/article/integrating-profiler-and-perfmon-log-files"&gt;&lt;strong&gt;&lt;font color="#004080"&gt;Integrating Profiler and PerfMon Log Files&lt;/font&gt;&lt;/strong&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://weblogs.sqlteam.com/mladenp/aggbug/60496.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Mladen Prajdić</dc:creator>
            <guid>http://weblogs.sqlteam.com/mladenp/archive/2008/02/08/Integrating-Profiler-and-PerfMon-Log-Files.aspx</guid>
            <pubDate>Fri, 08 Feb 2008 13:49:34 GMT</pubDate>
            <wfw:comment>http://weblogs.sqlteam.com/mladenp/comments/60496.aspx</wfw:comment>
            <comments>http://weblogs.sqlteam.com/mladenp/archive/2008/02/08/Integrating-Profiler-and-PerfMon-Log-Files.aspx#feedback</comments>
            <wfw:commentRss>http://weblogs.sqlteam.com/mladenp/comments/commentRss/60496.aspx</wfw:commentRss>
            <trackback:ping>http://weblogs.sqlteam.com/mladenp/services/trackbacks/60496.aspx</trackback:ping>
        </item>
        <item>
            <title>Back to Basics: Count, Count, Count, Sum or how to Count</title>
            <link>http://weblogs.sqlteam.com/mladenp/archive/2008/02/04/Back-to-Basics-Count-Count-Count-Sum-or-how-to.aspx</link>
            <description>&lt;p&gt;Probably everyone is familiar with the Count(*) function in SQL Server.&lt;/p&gt;
&lt;p&gt;But there seems to be a great deal of confusion amongst youngsters (SQL wise) about how all its possible options work.&lt;/p&gt;
&lt;p&gt;Let us banish the confusion back to the dark realms where in belongs to:&lt;/p&gt;
&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;DECLARE&lt;/span&gt; @t &lt;span class="kwrd"&gt;TABLE&lt;/span&gt; (val &lt;span class="kwrd"&gt;INT&lt;/span&gt;)
&lt;span class="kwrd"&gt;INSERT&lt;/span&gt; &lt;span class="kwrd"&gt;INTO&lt;/span&gt; @t
&lt;span class="kwrd"&gt;SELECT&lt;/span&gt; 1 &lt;span class="kwrd"&gt;UNION&lt;/span&gt; &lt;span class="kwrd"&gt;ALL&lt;/span&gt;
&lt;span class="kwrd"&gt;SELECT&lt;/span&gt; 1 &lt;span class="kwrd"&gt;UNION&lt;/span&gt; &lt;span class="kwrd"&gt;ALL&lt;/span&gt;
&lt;span class="kwrd"&gt;SELECT&lt;/span&gt; &lt;span class="kwrd"&gt;NULL&lt;/span&gt; &lt;span class="kwrd"&gt;UNION&lt;/span&gt; &lt;span class="kwrd"&gt;ALL&lt;/span&gt;
&lt;span class="kwrd"&gt;SELECT&lt;/span&gt; &lt;span class="kwrd"&gt;NULL&lt;/span&gt; &lt;span class="kwrd"&gt;UNION&lt;/span&gt; &lt;span class="kwrd"&gt;ALL&lt;/span&gt;
&lt;span class="kwrd"&gt;SELECT&lt;/span&gt; 4 &lt;span class="kwrd"&gt;UNION&lt;/span&gt; &lt;span class="kwrd"&gt;ALL&lt;/span&gt;
&lt;span class="kwrd"&gt;SELECT&lt;/span&gt; 4 &lt;span class="kwrd"&gt;UNION&lt;/span&gt; &lt;span class="kwrd"&gt;ALL&lt;/span&gt;
&lt;span class="kwrd"&gt;SELECT&lt;/span&gt; 5

&lt;span class="kwrd"&gt;SELECT&lt;/span&gt; &lt;span class="kwrd"&gt;COUNT&lt;/span&gt;(*) &lt;span class="kwrd"&gt;AS&lt;/span&gt; CountAll, &lt;span class="rem"&gt;-- counts all rows&lt;/span&gt;
       &lt;span class="kwrd"&gt;COUNT&lt;/span&gt;(val) &lt;span class="kwrd"&gt;AS&lt;/span&gt; CountAllNoNull, &lt;span class="rem"&gt;-- counts rows that don't contain NULL&lt;/span&gt;
       &lt;span class="kwrd"&gt;COUNT&lt;/span&gt;(&lt;span class="kwrd"&gt;DISTINCT&lt;/span&gt; val) &lt;span class="kwrd"&gt;AS&lt;/span&gt; CountDistinctNoNulls, &lt;span class="rem"&gt;-- counts the number of distinct values&lt;/span&gt;
       &lt;span class="kwrd"&gt;COUNT&lt;/span&gt;(*) - &lt;span class="kwrd"&gt;COUNT&lt;/span&gt;(val) &lt;span class="kwrd"&gt;AS&lt;/span&gt; CountOfNullValues &lt;span class="rem"&gt;-- count of NULL values in the column &lt;/span&gt;
&lt;span class="kwrd"&gt;FROM&lt;/span&gt;   @t
&lt;/pre&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;There are 3 ways in which Count() works:&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;COUNT(*)&lt;/strong&gt; - Counts all rows in the table&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;COUNT(ColumnName)&lt;/strong&gt; - Counts all rows in the table that don't contain NULL in the specified column&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;COUNT(DISTINCT ColumnName) &lt;/strong&gt;- Counts all DISTINCT rows in the table that don't contain NULL in the specified column&lt;/p&gt;
&lt;p&gt;We can see that with the use of these 3 options we can get easily get the number of NULL values in the column. &lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;So where does the Sum come in here? Sum can be used to get a count of practically anything with just one table scan.&lt;/p&gt;
&lt;p&gt;Let's illustrate:&lt;/p&gt;
&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;SELECT&lt;/span&gt; &lt;span class="kwrd"&gt;SUM&lt;/span&gt;(&lt;span class="kwrd"&gt;CASE&lt;/span&gt; &lt;span class="kwrd"&gt;WHEN&lt;/span&gt; val &amp;lt; 3 &lt;span class="kwrd"&gt;THEN&lt;/span&gt; 1 &lt;span class="kwrd"&gt;ELSE&lt;/span&gt; 0 &lt;span class="kwrd"&gt;END&lt;/span&gt;) &lt;span class="kwrd"&gt;AS&lt;/span&gt; LessThanTree,
       &lt;span class="kwrd"&gt;SUM&lt;/span&gt;(&lt;span class="kwrd"&gt;CASE&lt;/span&gt; &lt;span class="kwrd"&gt;WHEN&lt;/span&gt; val &amp;gt; 4 &lt;span class="kwrd"&gt;THEN&lt;/span&gt; 1 &lt;span class="kwrd"&gt;ELSE&lt;/span&gt; 0 &lt;span class="kwrd"&gt;END&lt;/span&gt;) &lt;span class="kwrd"&gt;AS&lt;/span&gt; MoreThanFour
       &lt;span class="rem"&gt;-- SUM(CASE WHEN &amp;lt;Any condition you can think of&amp;gt; THEN 1 ELSE 0 END) AS Col1&lt;/span&gt;
&lt;span class="kwrd"&gt;FROM&lt;/span&gt;   @t&lt;/pre&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;To follow the primary school logic here: &lt;/p&gt;
&lt;p&gt;If something fits the condition return 1 else return 0. The sum of all 1's returns the number of items that satisfy the desired condition.&lt;/p&gt;
&lt;p&gt;And the condition is limited only by your business requirement.&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;You see there's no need to write nested select statements similar to this:&lt;/p&gt;
&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;SELECT&lt;/span&gt; (&lt;span class="kwrd"&gt;SELECT&lt;/span&gt; &lt;span class="kwrd"&gt;COUNT&lt;/span&gt;(*) &lt;span class="kwrd"&gt;FROM&lt;/span&gt; MyTable &lt;span class="kwrd"&gt;WHERE&lt;/span&gt; &amp;lt;someCondition1&amp;gt;) &lt;span class="kwrd"&gt;AS&lt;/span&gt; cnt1, 
       (&lt;span class="kwrd"&gt;SELECT&lt;/span&gt; &lt;span class="kwrd"&gt;COUNT&lt;/span&gt;(*) &lt;span class="kwrd"&gt;FROM&lt;/span&gt; MyTable &lt;span class="kwrd"&gt;WHERE&lt;/span&gt; &amp;lt;someCondition1&amp;gt;) &lt;span class="kwrd"&gt;AS&lt;/span&gt; cnt2&lt;/pre&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;&lt;a target="_blank" href="http://weblogs.sqlteam.com/jeffs/"&gt;&lt;strong&gt;&lt;font color="#004080"&gt;Jeff&lt;/font&gt;&lt;/strong&gt;&lt;/a&gt; has also has a good post about translating these kind of queries to case statements &lt;a target="_blank" href="http://weblogs.sqlteam.com/jeffs/archive/2008/01/09/rewrite-correlated-sub-query-with-case-sql.aspx"&gt;&lt;strong&gt;&lt;font color="#004080"&gt;here&lt;/font&gt;&lt;/strong&gt;&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;And this might even provide a nice interview question...&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;a href="http://www.dotnetkicks.com/kick/?url=http%3a%2f%2fweblogs.sqlteam.com%2fmladenp%2farchive%2f2008%2f02%2f04%2fBack-to-Basics-Count-Count-Count-Sum-or-how-to.aspx"&gt;&lt;img src="http://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url=http%3a%2f%2fweblogs.sqlteam.com%2fmladenp%2farchive%2f2008%2f02%2f04%2fBack-to-Basics-Count-Count-Count-Sum-or-how-to.aspx" border="0" alt="kick it on DotNetKicks.com" /&gt;&lt;/a&gt;&lt;img src="http://weblogs.sqlteam.com/mladenp/aggbug/60485.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Mladen Prajdić</dc:creator>
            <guid>http://weblogs.sqlteam.com/mladenp/archive/2008/02/04/Back-to-Basics-Count-Count-Count-Sum-or-how-to.aspx</guid>
            <pubDate>Mon, 04 Feb 2008 16:24:04 GMT</pubDate>
            <wfw:comment>http://weblogs.sqlteam.com/mladenp/comments/60485.aspx</wfw:comment>
            <comments>http://weblogs.sqlteam.com/mladenp/archive/2008/02/04/Back-to-Basics-Count-Count-Count-Sum-or-how-to.aspx#feedback</comments>
            <slash:comments>1</slash:comments>
            <wfw:commentRss>http://weblogs.sqlteam.com/mladenp/comments/commentRss/60485.aspx</wfw:commentRss>
            <trackback:ping>http://weblogs.sqlteam.com/mladenp/services/trackbacks/60485.aspx</trackback:ping>
        </item>
        <item>
            <title>Introduction to locking in SQL Server 2005</title>
            <link>http://weblogs.sqlteam.com/mladenp/archive/2007/12/12/Introduction-to-locking-in-SQL-Server-2005.aspx</link>
            <description>&lt;p&gt; &lt;/p&gt;
&lt;p&gt;I've written an article here on &lt;a target="_blank" href="http://www.sqlteam.com"&gt;&lt;strong&gt;&lt;font color="#004080"&gt;SQL Team&lt;/font&gt;&lt;/strong&gt;&lt;/a&gt; about locking in SQL Server. &lt;/p&gt;
&lt;p&gt;It's an introductory article that shows lock modes, lock granularity and lock compatibility matrix&lt;/p&gt;
&lt;p&gt;and it will be followed by a few more advanced ones on the topic of locking.&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;Part 1:  &lt;a target="_blank" href="http://www.sqlteam.com/article/introduction-to-locking-in-sql-server"&gt;&lt;font color="#004080"&gt;&lt;strong&gt;Introduction to locking in SQL Server 2005&lt;/strong&gt;&lt;/font&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://weblogs.sqlteam.com/mladenp/aggbug/60428.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Mladen Prajdić</dc:creator>
            <guid>http://weblogs.sqlteam.com/mladenp/archive/2007/12/12/Introduction-to-locking-in-SQL-Server-2005.aspx</guid>
            <pubDate>Wed, 12 Dec 2007 19:36:13 GMT</pubDate>
            <wfw:comment>http://weblogs.sqlteam.com/mladenp/comments/60428.aspx</wfw:comment>
            <comments>http://weblogs.sqlteam.com/mladenp/archive/2007/12/12/Introduction-to-locking-in-SQL-Server-2005.aspx#feedback</comments>
            <slash:comments>2</slash:comments>
            <wfw:commentRss>http://weblogs.sqlteam.com/mladenp/comments/commentRss/60428.aspx</wfw:commentRss>
            <trackback:ping>http://weblogs.sqlteam.com/mladenp/services/trackbacks/60428.aspx</trackback:ping>
        </item>
        <item>
            <title>SQL Server 2005: Synonyms in T-SQL (analogous to Aliases in .Net)</title>
            <link>http://weblogs.sqlteam.com/mladenp/archive/2007/11/26/SQL-Server-2005-Synonyms-in-T-SQL-analogous-to-Aliases-in.aspx</link>
            <description>&lt;p&gt;If you're a .Net developer aliases should be very familiar to you.&lt;/p&gt; &lt;p&gt;if they're not here is a reminder:&lt;/p&gt;&lt;!-- code formatted by http://manoli.net/csharpformat/ --&gt;&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;using&lt;/span&gt; MyAlias = This.Is.My.Full.Namespace.MyClass;
MyAlias m = &lt;span class="kwrd"&gt;new&lt;/span&gt; MyAlias(); &lt;span class="rem"&gt;// MyAlias is of course of type MyClass&lt;/span&gt;
&lt;/pre&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;Well it seems SQL Server 2005 added a similar functionality to T-SQL. It's called &lt;strong&gt;Synonyms&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;You can use them in all CRUD operations as well as in sub-selects and dynamic SQL&lt;/p&gt;
&lt;p&gt;What's interesting is that synonyms are evaluated at run time and the binding between the synonym and an object is by name only.&lt;/p&gt;
&lt;p&gt;This means that you can drop the object referenced by the synonym at any time, but you'll get an error only at run-time.&lt;/p&gt;
&lt;p&gt;They are useful because they provide a level of abstraction in your app, since you can change the name or even a location of the object &lt;/p&gt;
&lt;p&gt;referenced by the synonym.&lt;/p&gt;
&lt;p&gt;And not to mention having less to type as seen in this example: &lt;/p&gt;&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;USE&lt;/span&gt; tempdb;
&lt;span class="kwrd"&gt;GO&lt;/span&gt;
&lt;span class="rem"&gt;-- Create a synonym for the Product table in AdventureWorks.&lt;/span&gt;
&lt;span class="kwrd"&gt;CREATE&lt;/span&gt; SYNONYM MyProduct
&lt;span class="kwrd"&gt;FOR&lt;/span&gt; AdventureWorks.Production.Product;
&lt;span class="kwrd"&gt;GO&lt;/span&gt;

&lt;span class="rem"&gt;-- Query the Product table by using the synonym.&lt;/span&gt;
&lt;span class="kwrd"&gt;USE&lt;/span&gt; tempdb;
&lt;span class="kwrd"&gt;GO&lt;/span&gt;
&lt;span class="kwrd"&gt;SELECT&lt;/span&gt; ProductID, Name 
&lt;span class="kwrd"&gt;FROM&lt;/span&gt; MyProduct
&lt;span class="kwrd"&gt;WHERE&lt;/span&gt; ProductID &amp;lt; 5;
GO&lt;/pre&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;These database objects can be referenced by a synonym:&lt;/p&gt;
&lt;p&gt;- SQL stored procedures, scalar, table-valued and inline-tabled-valued functions &lt;/p&gt;
&lt;p&gt;- Views &lt;/p&gt;
&lt;p&gt;- Local and global temporary tables&lt;/p&gt;
&lt;p&gt;- Replication-filter and extended stored procedures &lt;/p&gt;
&lt;p&gt;- CLR stored procedures, table-valued, scalar and aggregate functions &lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;Don't know in how widespread use this will be but it's a nice feature that can come in handy.&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;&lt;a href="http://www.dotnetkicks.com/kick/?url=http%3a%2f%2fweblogs.sqlteam.com%2fmladenp%2farchive%2f2007%2f11%2f26%2fSQL-Server-2005-Synonyms-in-T-SQL-analogous-to-Aliases-in.aspx"&gt;&lt;img alt="kick it on DotNetKicks.com" src="http://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url=http%3a%2f%2fweblogs.sqlteam.com%2fmladenp%2farchive%2f2007%2f11%2f26%2fSQL-Server-2005-Synonyms-in-T-SQL-analogous-to-Aliases-in.aspx" border="0" /&gt;&lt;/a&gt;&lt;img src="http://weblogs.sqlteam.com/mladenp/aggbug/60413.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Mladen Prajdić</dc:creator>
            <guid>http://weblogs.sqlteam.com/mladenp/archive/2007/11/26/SQL-Server-2005-Synonyms-in-T-SQL-analogous-to-Aliases-in.aspx</guid>
            <pubDate>Mon, 26 Nov 2007 20:37:26 GMT</pubDate>
            <wfw:comment>http://weblogs.sqlteam.com/mladenp/comments/60413.aspx</wfw:comment>
            <comments>http://weblogs.sqlteam.com/mladenp/archive/2007/11/26/SQL-Server-2005-Synonyms-in-T-SQL-analogous-to-Aliases-in.aspx#feedback</comments>
            <slash:comments>5</slash:comments>
            <wfw:commentRss>http://weblogs.sqlteam.com/mladenp/comments/commentRss/60413.aspx</wfw:commentRss>
            <trackback:ping>http://weblogs.sqlteam.com/mladenp/services/trackbacks/60413.aspx</trackback:ping>
        </item>
        <item>
            <title>Free SQL Server tools that might make your life a little easier</title>
            <link>http://weblogs.sqlteam.com/mladenp/archive/2007/11/20/Free-SQL-Server-tools-that-might-make-your-life-a.aspx</link>
            <description>&lt;p&gt;Update: New Stuff from the latest update will be in &lt;font color="#ff0000"&gt;&lt;strong&gt;RED&lt;/strong&gt;.&lt;/font&gt;&lt;/p&gt; &lt;p&gt;This list will grow as I find new tools. So if you know of some not on this list do post them in the comments.&lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;p&gt;&lt;strong&gt;SQL Server Management Studio Add-in's&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;&lt;a href="http://weblogs.sqlteam.com/mladenp/archive/2007/12/07/SSMS-Tools-Pack-0.9.5-add-in-for-SQL-Server-Management.aspx" target="_blank"&gt;&lt;strong&gt;&lt;font color="#004080"&gt;SSMS Tools Pack&lt;/font&gt;&lt;/strong&gt;&lt;/a&gt; - an add-in with lots of IDE options (Query Execution history, regions, debug sections, CRUD stored procedures creation, new query templates, running custom scripts from Object explorer's context menu) for SQL Server Management Studio and SQL Server Management Studio Express&lt;/p&gt; &lt;p&gt;&lt;a href="http://sqlblogcasts.com/blogs/seanprice/archive/2007/08/28/data-scripter-add-in-for-management-studio.aspx" target="_blank"&gt;&lt;strong&gt;&lt;font color="#004080"&gt;Data Scripter&lt;/font&gt;&lt;/strong&gt;&lt;/a&gt; - generates insert statements for a table&lt;/p&gt; &lt;p&gt;&lt;a href="http://sqlblogcasts.com/blogs/seanprice/archive/2007/07/15/sql-management-studio-snapshot-add-in.aspx" target="_blank"&gt;&lt;strong&gt;&lt;font color="#004080"&gt;Create Database Snapshot&lt;/font&gt;&lt;/strong&gt;&lt;/a&gt; - simple GUI for creating a database snapshot &lt;/p&gt; &lt;p&gt;&lt;a href="http://www.sqldbatips.com/showarticle.asp?ID=78" target="_blank"&gt;&lt;strong&gt;&lt;font color="#004080"&gt;Sort SQL Project Files&lt;/font&gt;&lt;/strong&gt;&lt;/a&gt; - sorts SQL project files&lt;/p&gt; &lt;p&gt;&lt;a href="http://jcooney.net/archive/2007/11/26/55358.aspx"&gt;&lt;strong&gt;&lt;font color="#004080"&gt;The Black Art of Writing a SQL Server Management Studio 2005 Add-In&lt;/font&gt;&lt;/strong&gt;&lt;/a&gt; - a how-to article and a Search DB Objects add-in with code&lt;/p&gt; &lt;p&gt;&lt;a href="http://aspalliance.com/1374_Extend_Functionality_in_SQL_Server_2005_Management_Studio_with_Addins.all" target="_blank"&gt;&lt;strong&gt;&lt;font color="#004080"&gt;How to create SSMS Add-in&lt;/font&gt;&lt;/strong&gt;&lt;/a&gt; - an article that describes how to create add-ins without any source code&lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;p&gt;&lt;strong&gt;Administration&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;&lt;a href="http://www.sqlinternalsviewer.com/" target="_blank"&gt;&lt;strong&gt;&lt;font color="#ff0000"&gt;SQL Internals Viewer&lt;/font&gt;&lt;/strong&gt;&lt;/a&gt; - a tool for looking into the SQL Server storage engine and seeing how data is physically allocated, organised and stored.&lt;/p&gt; &lt;p&gt;&lt;a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=8c0f970e-c653-4c15-9e51-6a6cadfca363&amp;amp;DisplayLang=en" target="_blank"&gt;&lt;strong&gt;&lt;font color="#ff0000"&gt;Microsoft SQL Server 2000/2005 Management Pack&lt;/font&gt;&lt;/strong&gt;&lt;/a&gt; - monitors the availability and performance of SQL Server 2000 and 2005 and can issue alerts for configuration problems.&lt;/p&gt; &lt;p&gt;&lt;a href="http://www.codeplex.com/PAL" target="_blank"&gt;&lt;strong&gt;&lt;font color="#004080"&gt;Performance Analysis of Logs (PAL) Tool&lt;/font&gt;&lt;/strong&gt;&lt;/a&gt; - tool that reads in a performance monitor counter log (any known format) and analyzes it using complex, but known thresholds (provided).&lt;/p&gt;&lt;strong&gt;&lt;/strong&gt; &lt;p&gt;&lt;a href="http://www.microsoft.com/technet/security/tools/mbsa2_1/default.mspx" target="_blank"&gt;&lt;strong&gt;&lt;font color="#004080"&gt;Microsoft Baseline Security Analyzer&lt;/font&gt;&lt;/strong&gt;&lt;/a&gt; - helps small- and medium-sized businesses determine their security state in accordance with Microsoft security recommendations and offers specific remediation guidance&lt;/p&gt; &lt;p&gt;&lt;a href="http://www.microsoft.com/downloads/details.aspx?FamilyId=7EDFA95A-A32F-440F-A3A8-5160C8DBE926&amp;amp;displaylang=en" target="_blank"&gt;&lt;strong&gt;&lt;font color="#004080"&gt;RML Utilities for SQL Server (x86)&lt;/font&gt;&lt;/strong&gt;&lt;/a&gt; and &lt;a href="http://www.microsoft.com/downloads/details.aspx?FamilyId=B60CDFA3-732E-4347-9C06-2D1F1F84C342&amp;amp;displaylang=en" target="_blank"&gt;&lt;strong&gt;&lt;font color="#004080"&gt;(x64)&lt;/font&gt;&lt;/strong&gt;&lt;/a&gt; - tools to help database administrators manage the performance of Microsoft SQL Server: &lt;a href="http://blogs.msdn.com/psssql/archive/2007/12/18/rml-utilities-for-microsoft-sql-server-released.aspx" target="_blank"&gt;&lt;strong&gt;&lt;font color="#004080"&gt;Overview&lt;/font&gt;&lt;/strong&gt;&lt;/a&gt;&lt;/p&gt; &lt;p&gt;&lt;a href="http://sqlblog.com/blogs/kevin_kline/archive/2007/12/20/sqldumper.aspx" target="_blank"&gt;&lt;strong&gt;&lt;font color="#004080"&gt;SQLDumper.exe&lt;/font&gt;&lt;/strong&gt;&lt;/a&gt; - comes with SQL Server. Installed at &lt;strong&gt;..\Microsoft SQL Server\90\Shared\SQLDumper.exe.&lt;/strong&gt; Generates a dump file on demand for any Microsoft Windows application.&lt;/p&gt; &lt;p&gt;&lt;a href="http://www.codeplex.com/sql2005partitionmgmt" target="_blank"&gt;&lt;strong&gt;&lt;font color="#004080"&gt;SQL Server 2005 Partition Management&lt;/font&gt;&lt;/strong&gt;&lt;/a&gt; - helps in data loading and extraction from partitions&lt;/p&gt; &lt;p&gt;&lt;a href="http://msdn2.microsoft.com/en-us/library/ms162833.aspx" target="_blank"&gt;&lt;strong&gt;&lt;font color="#004080"&gt;SQLdiag Utility&lt;/font&gt;&lt;/strong&gt;&lt;/a&gt; - a general purpose diagnostics collection utility that can be run as a console application or as a service (comes with SQL Server)&lt;/p&gt; &lt;p&gt;&lt;a href="http://www.sqlnexus.net/" target="_blank"&gt;&lt;strong&gt;&lt;font color="#004080"&gt;SQL Nexus&lt;/font&gt;&lt;/strong&gt;&lt;/a&gt; - analyzes SQLDIAG captures&lt;/p&gt; &lt;p&gt;&lt;a href="http://www.microsoft.com/downloads/details.aspx?familyid=5564386A-28C2-4483-8293-76FFF67B9EB3&amp;amp;displaylang=en" target="_blank"&gt;&lt;strong&gt;&lt;font color="#004080"&gt;PSSDiag Utility&lt;/font&gt;&lt;/strong&gt;&lt;/a&gt; - a general purpose diagnostic collection utility that Microsoft Product Support Services uses to collect various logs and data files&lt;/p&gt; &lt;p&gt;&lt;a href="http://www.specialopssecurity.com/labs/sqlrecon/ " target="_blank"&gt;&lt;strong&gt;&lt;font color="#004080"&gt;SQL Recon&lt;/font&gt;&lt;/strong&gt;&lt;/a&gt; - performs active and passive scans of your network in order to identify all of the SQL Server/MSDE installations in your enterprise&lt;/p&gt; &lt;p&gt;&lt;a href="http://www.sqlinternalsviewer.com/" target="_blank"&gt;&lt;strong&gt;&lt;font color="#004080"&gt;SQL Internals Viewer&lt;/font&gt;&lt;/strong&gt;&lt;/a&gt; - looks into the SQL Server storage engine seeing how data is physically allocated, organized and stored.&lt;/p&gt; &lt;p&gt;&lt;a href="http://sqlprofiler.googlepages.com" target="_blank"&gt;&lt;strong&gt;&lt;font color="#004080"&gt;SQL Server 2005 Express Profiler&lt;/font&gt;&lt;/strong&gt;&lt;/a&gt; - a free SQL Profiler for SQL Express &lt;/p&gt; &lt;p&gt;&lt;a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=890cd06b-abf8-4c25-91b2-f8d975cf8c07&amp;amp;displaylang=en" target="_blank"&gt;&lt;strong&gt;&lt;font color="#004080"&gt;Log Parser 2.2&lt;/font&gt;&lt;/strong&gt;&lt;/a&gt; - provides query access to log files, XML files and CSV files, the Event Log, the Registry, the file system, and Active Directory&lt;/p&gt; &lt;p&gt;&lt;a href="http://www.microsoft.com/downloads/details.aspx?FamilyId=C243A5AE-4BD1-4E3D-94B8-5A0F62BF7796&amp;amp;displaylang=en"&gt;&lt;strong&gt;&lt;font color="#004080"&gt;Microsoft SQL Server Management Studio Express&lt;/font&gt;&lt;/strong&gt;&lt;/a&gt; - apparently a lot of people don't know this exists. Stripped down version of SSMS&lt;/p&gt; &lt;p&gt;&lt;a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=2ec9e842-40be-4321-9b56-92fd3860fb32&amp;amp;DisplayLang=en" target="_blank"&gt;&lt;strong&gt;&lt;font color="#004080"&gt;SQL Server 2005 System Views Map&lt;/font&gt;&lt;/strong&gt;&lt;/a&gt; - a nice map of all the DMV's and links between them&lt;/p&gt; &lt;p&gt;&lt;a href="http://www.codeplex.com/SqlWebAdmin" target="_blank"&gt;&lt;strong&gt;&lt;font color="#004080"&gt;SQL Server Web Data Administrator&lt;/font&gt;&lt;/strong&gt;&lt;/a&gt; - admin your SQL Server over the web&lt;/p&gt; &lt;p&gt;&lt;a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=fa87e828-173f-472e-a85c-27ed01cf6b02&amp;amp;DisplayLang=en" target="_blank"&gt;&lt;strong&gt;&lt;font color="#004080"&gt;SQL Server Express Utility&lt;/font&gt;&lt;/strong&gt;&lt;/a&gt; - simple interaction with SQL Server&lt;/p&gt; &lt;p&gt;&lt;a href="http://weblogs.sqlteam.com/mladenp/archive/2007/08/10/60279.aspx" target="_blank"&gt;&lt;strong&gt;&lt;font color="#004080"&gt;TableDiff.exe&lt;/font&gt;&lt;/strong&gt;&lt;/a&gt; - utility that compares 2 tables for differences in data and schema for SQL Server 2000 and 2005&lt;/p&gt; &lt;p&gt;&lt;a href="http://www.codeplex.com/sqldmvstats" target="_blank"&gt;&lt;strong&gt;&lt;font color="#004080"&gt;DMVStats&lt;/font&gt;&lt;/strong&gt;&lt;/a&gt; - collects, analyzes and reports on SQL Server 2005 DMV performance data&lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;p&gt;&lt;strong&gt;Best practices, analysis, health and performance&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;&lt;a href="http://www.microsoft.com/downloads/details.aspx?familyid=976df931-a3cf-40e3-802e-3281b1451835&amp;amp;displaylang=en&amp;amp;tm" target="_blank"&gt;&lt;strong&gt;&lt;font color="#004080"&gt;SQL Server 2005 Assessment Configuration Pack for Sarbanes-Oxley Act (SOX)&lt;/font&gt;&lt;/strong&gt;&lt;/a&gt; - contains configuration items intended to help you establish and validate a desired configuration for your SQL 2005 servers in order to support your Sarbanes-Oxley compliance efforts&lt;/p&gt; &lt;p&gt;&lt;a href="http://www.usaupload.net/d/4qmkm6bg5k4" target="_blank"&gt;&lt;strong&gt;&lt;font color="#004080"&gt;SQLIO GUI&lt;/font&gt;&lt;/strong&gt;&lt;/a&gt; - user interface for SQLIO Disk Subsystem Benchmark Tool&lt;/p&gt; &lt;p&gt;&lt;a href="http://www.datamanipulation.net/SQLQueryStress/"&gt;&lt;strong&gt;&lt;font color="#004080"&gt;SQLQueryStress&lt;/font&gt;&lt;/strong&gt;&lt;/a&gt; -  automatically collects metrics to help you determine whether your queries will perform under load, and what kind of resource strain they put on your server&lt;/p&gt; &lt;p&gt;&lt;a href="http://www.microsoft.com/downloads/details.aspx?familyid=9A8B005B-84E4-4F24-8D65-CB53442D9E19&amp;amp;displaylang=en" target="_blank"&gt;&lt;strong&gt;&lt;font color="#004080"&gt;SQLIO Disk Subsystem Benchmark Tool&lt;/font&gt;&lt;/strong&gt;&lt;/a&gt; - used to determine the I/O capacity of a given configuration&lt;/p&gt; &lt;p&gt;&lt;a href="http://www.microsoft.com/downloads/details.aspx?FamilyId=DA0531E4-E94C-4991-82FA-F0E3FBD05E63&amp;amp;displaylang=en" target="_blank"&gt;&lt;strong&gt;&lt;font color="#004080"&gt;SQL Server 2005 Best Practices Analyzer&lt;/font&gt;&lt;/strong&gt;&lt;/a&gt; - lets you verify the implementation of common Best Practices in SQL Server 2005&lt;/p&gt; &lt;p&gt;&lt;a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=b352eb1f-d3ca-44ee-893e-9e07339c1f22&amp;amp;displaylang=en" target="_blank"&gt;&lt;strong&gt;&lt;font color="#004080"&gt;SQL Server 2000 Best Practices Analyzer&lt;/font&gt;&lt;/strong&gt;&lt;/a&gt; - lets you verify the implementation of common Best Practices in SQL Server 2000&lt;/p&gt; &lt;p&gt;&lt;a href="http://www.microsoft.com/downloads/details.aspx?familyid=EEDD10D6-75F7-4763-86DE-D2347B8B5F89&amp;amp;displaylang=en" target="_blank"&gt;&lt;strong&gt;&lt;font color="#004080"&gt;SQL Server Health and History Tool (SQLH2)&lt;/font&gt;&lt;/strong&gt;&lt;/a&gt; - collects information from instances of SQL Server to determine how SQL Server is being used&lt;/p&gt; &lt;p&gt;&lt;a href="http://www.microsoft.com/downloads/details.aspx?familyid=64983AF0-7902-427E-9B41-7C2E8FDCC140&amp;amp;displaylang=en" target="_blank"&gt;&lt;strong&gt;&lt;font color="#004080"&gt;SQL Server Health and History Tool (SQLH2) Performance Collector&lt;/font&gt;&lt;/strong&gt;&lt;/a&gt; - optional tool to collect performance counters that are consumed by the SQLH2&lt;/p&gt; &lt;p&gt;&lt;a href="http://www.microsoft.com/downloads/details.aspx?familyid=A4B837C7-A1FA-4F25-840B-FEF15E917F18&amp;amp;displaylang=en" target="_blank"&gt;&lt;strong&gt;&lt;font color="#004080"&gt;SQL Server Health and History Tool (SQLH2) Reports&lt;/font&gt;&lt;/strong&gt;&lt;/a&gt; - reports needed to view the data collected by the SQLH2&lt;/p&gt; &lt;p&gt;&lt;a href="http://www.microsoft.com/downloads/details.aspx?familyid=1D3A4A0D-7E0C-4730-8204-E419218C1EFC&amp;amp;displaylang=en" target="_blank"&gt;&lt;strong&gt;&lt;font color="#004080"&gt;SQL Server 2005 Performance Dashboard Reports&lt;/font&gt;&lt;/strong&gt;&lt;/a&gt; - performance reports that integrate into SQL Server Management Studio&lt;/p&gt; &lt;p&gt;&lt;a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=8c0f970e-c653-4c15-9e51-6a6cadfca363&amp;amp;DisplayLang=en" target="_blank"&gt;&lt;strong&gt;&lt;font color="#004080"&gt;Microsoft SQL Server 2000/2005 Management Pack&lt;/font&gt;&lt;/strong&gt;&lt;/a&gt; - monitors the availability and performance of SQL Server 2000 and 2005 and can issue alerts for configuration problems&lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;p&gt;&lt;strong&gt;Database Publishing to hosted servers&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;&lt;a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=56e5b1c5-bf17-42e0-a410-371a838e570a&amp;amp;DisplayLang=en" target="_blank"&gt;&lt;strong&gt;&lt;font color="#004080"&gt;Microsoft SQL Server Database Publishing Wizard&lt;/font&gt;&lt;/strong&gt;&lt;/a&gt; - provides a way to publish databases to T-SQL scripts or directly to supporting hosting service providers&lt;/p&gt; &lt;p&gt;&lt;a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=6f03273c-ffc8-4f5e-bafc-041fbd68fd1e&amp;amp;DisplayLang=en" target="_blank"&gt;&lt;strong&gt;&lt;font color="#004080"&gt;Microsoft SQL Server Database Publishing Services&lt;/font&gt;&lt;/strong&gt;&lt;/a&gt; - deployed by shared hosting providers to enable publishing of SQL Server databases over the Internet&lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;p&gt;&lt;strong&gt;Upgrade and Migration&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;&lt;a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=1470e86b-7e05-4322-a677-95ab44f12d75&amp;amp;DisplayLang=en" target="_blank"&gt;&lt;strong&gt;&lt;font color="#004080"&gt;Microsoft SQL Server 2005 Upgrade Advisor&lt;/font&gt;&lt;/strong&gt;&lt;/a&gt; - used when upgrading from lower SQL Server version to SQL Server 2005&lt;/p&gt; &lt;p&gt;&lt;a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=d842f8b4-c914-4ac7-b2f3-d25fff4e24fb&amp;amp;DisplayLang=en" target="_blank"&gt;&lt;strong&gt;&lt;font color="#004080"&gt;SQL Server Migration Assistant for Access&lt;/font&gt;&lt;/strong&gt;&lt;/a&gt;&lt;/p&gt; &lt;p&gt;&lt;a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=e35cee88-c919-463f-b020-81468cd231da&amp;amp;DisplayLang=en" target="_blank"&gt;&lt;strong&gt;&lt;font color="#004080"&gt;SQL Server Migration Assistant for Oracle&lt;/font&gt;&lt;/strong&gt;&lt;/a&gt;&lt;/p&gt; &lt;p&gt;&lt;a href="http://www.microsoft.com/downloads/details.aspx?FamilyId=5F63E592-1BD0-492E-9CE6-29270AE671C3&amp;amp;displaylang=en" target="_blank"&gt;&lt;strong&gt;&lt;font color="#004080"&gt;SQL Server Migration Assistant for Sybase ASE&lt;/font&gt;&lt;/strong&gt;&lt;/a&gt;&lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;p&gt;&lt;strong&gt;SQL Server Analysis Services&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;&lt;a href="http://www.codeplex.com/mdxscriptperf"&gt;&lt;strong&gt;&lt;font color="#004080"&gt;MDX Script Performance Analyser&lt;/font&gt;&lt;/strong&gt;&lt;/a&gt; - allows the user to identify how much each calculated member, named set and scoped assignment in an Analysis Services cube's MDX script contributes to the overall performance of a given MDX query.&lt;/p&gt; &lt;p&gt;&lt;a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=7c76e8df-8674-4c3b-a99b-55b17f3c4c51&amp;amp;DisplayLang=en" target="_blank"&gt;&lt;strong&gt;&lt;font color="#004080"&gt;Microsoft SQL Server 2005 Data Mining Add-ins for Microsoft Office 2007&lt;/font&gt;&lt;/strong&gt;&lt;/a&gt; - SQL Server 2005 predictive analytics in Office Excel 2007 and Office Visio 2007&lt;/p&gt; &lt;p&gt;&lt;strong&gt;&lt;/strong&gt; &lt;/p&gt; &lt;p&gt;&lt;strong&gt;SQL Server Integration Services&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;&lt;a href="http://www.codeplex.com/DTLoggedExec" target="_blank"&gt;&lt;strong&gt;&lt;font color="#004080"&gt;DTLoggedExec&lt;/font&gt;&lt;/strong&gt;&lt;/a&gt;  - allows you to run a Sql Server Integration Services (SSIS) Package producing a full and detailed logging information of execution status and package runtime data.&lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;p&gt;&lt;strong&gt;SQL Server 2005 BI Development Studio (BIDS)&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;&lt;a href="http://www.codeplex.com/bidshelper"&gt;&lt;strong&gt;&lt;font color="#004080"&gt;BIDS Helper&lt;/font&gt;&lt;/strong&gt;&lt;/a&gt; - Add-in for Visual Studio Business Intelligence Development Studio&lt;/p&gt; &lt;p&gt;&lt;strong&gt;&lt;/strong&gt; &lt;/p&gt; &lt;p&gt;&lt;strong&gt;Samples&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;&lt;a href="http://www.codeplex.com/MSFTASProdSamples"&gt;&lt;strong&gt;&lt;font color="#004080"&gt;SQL Server Analysis Services Product Samples&lt;/font&gt;&lt;/strong&gt;&lt;/a&gt;&lt;/p&gt; &lt;p&gt;&lt;a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=e719ecf7-9f46-4312-af89-6ad8702e4e6e&amp;amp;DisplayLang=en" target="_blank"&gt;&lt;strong&gt;&lt;font color="#004080"&gt;SQL Server 2005 Samples and Sample Databases&lt;/font&gt;&lt;/strong&gt;&lt;/a&gt;&lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;p&gt;&lt;strong&gt;Non MS stuff&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;&lt;a href="http://nielsb.wordpress.com/sqlclrproject/" target="_blank"&gt;&lt;strong&gt;&lt;font color="#004080"&gt;SQL CLR Project&lt;/font&gt;&lt;/strong&gt;&lt;/a&gt; - a tool that allows you to deploy .NET assemblies to SQL Server. Pretty COOL if you work with SQL CLR a lot&lt;/p&gt; &lt;p&gt;&lt;a href="http://ondras.zarovi.cz/sql/demo/" target="_blank"&gt;&lt;strong&gt;&lt;font color="#004080"&gt;SQL Designer&lt;/font&gt;&lt;/strong&gt;&lt;/a&gt; - online SQL Database designer. Contains Importing and Exporting scripts to and from different formats&lt;/p&gt; &lt;p&gt;&lt;a href="www.codeplex.com/dbdiff" target="_blank"&gt;&lt;strong&gt;&lt;font color="#004080"&gt;DbDiff and DbScripting&lt;/font&gt;&lt;/strong&gt;&lt;/a&gt; - Compare SQL Server database structures and generate scripts&lt;/p&gt; &lt;p&gt;&lt;a href="http://www.sqleffects.com/Articles/Product/sqlAccordInfo/aboutSqlAccordCommunityEd.html" target="_blank"&gt;&lt;strong&gt;&lt;font color="#004080"&gt;SQL Accord Community Edition&lt;/font&gt;&lt;/strong&gt;&lt;/a&gt; - compares database schema&lt;/p&gt; &lt;p&gt;&lt;a href="http://www.quest.com/Comparison-Suite-for-SQL-Server/" target="_blank"&gt;&lt;strong&gt;&lt;font color="#004080"&gt;Quest software's Comparison Suite for SQL Server&lt;/font&gt;&lt;/strong&gt;&lt;/a&gt; - tried it... pretty slick&lt;/p&gt; &lt;p&gt;&lt;a href="http://www.bypsoft.com"&gt;&lt;strong&gt;&lt;font color="#004080"&gt;Bypsoft's DBTYP.NET&lt;/font&gt;&lt;/strong&gt;&lt;/a&gt; - compares SQL Server, MySQL and Oracle databases. Cross database comparison of schemas and data.&lt;/p&gt; &lt;p&gt;&lt;a href="http://www.sqldbtools.com"&gt;&lt;strong&gt;&lt;font color="#004080"&gt;SQL DB Tools&lt;/font&gt;&lt;/strong&gt;&lt;/a&gt; - SqlDbDiff, SqlDbSearch and SqlDbSize utility&lt;/p&gt; &lt;p&gt;&lt;a href="http://www.cleardata.biz/cleartrace/" target="_blank"&gt;&lt;strong&gt;&lt;font color="#004080"&gt;ClearTrace&lt;/font&gt;&lt;/strong&gt;&lt;/a&gt; - utility to easier read your saved trace files &lt;/p&gt; &lt;p&gt;&lt;a href="http://www.sqlscripter.com/" target="_blank"&gt;&lt;strong&gt;&lt;font color="#004080"&gt;SQL Sripter&lt;/font&gt;&lt;/strong&gt;&lt;/a&gt; - data export and scripting utility for Microsoft SQL Server&lt;/p&gt; &lt;p&gt;&lt;a href="http://www.codeplex.com/ScriptDB" target="_blank"&gt;&lt;strong&gt;&lt;font color="#004080"&gt;ScriptDb&lt;/font&gt;&lt;/strong&gt;&lt;/a&gt; - data export and scripting utility for Microsoft SQL Server&lt;/p&gt; &lt;p&gt;&lt;a href="http://www.idera.com/FreeTools/" target="_blank"&gt;&lt;strong&gt;&lt;font color="#004080"&gt;Idera's Free Tools&lt;/font&gt;&lt;/strong&gt;&lt;/a&gt; - SQL Server backup and recovery tool, performance dashboard and logons and permissions transfer tool &lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;p&gt;&lt;strong&gt;SQL and other code Formatting&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;&lt;a href="http://www.manoli.net/csharpformat/"&gt;&lt;strong&gt;&lt;font color="#004080"&gt;Jean-Claude Manoli's code formater&lt;/font&gt;&lt;/strong&gt;&lt;/a&gt; - online formatting. I use this for my blog's code formatting. Has source code download and formats C#, VB, HTML/XML/ASPX  , T-SQL and MSH&lt;/p&gt; &lt;p&gt;&lt;a href="http://www.sqlinform.com/"&gt;&lt;strong&gt;&lt;font color="#004080"&gt;SQLinForm&lt;/font&gt;&lt;/strong&gt;&lt;/a&gt; - online and desktop versions&lt;/p&gt; &lt;p&gt;&lt;a href="http://www.simple-talk.com/prettifier/default.php"&gt;&lt;strong&gt;&lt;font color="#004080"&gt;Simple Talk's Prettifier&lt;/font&gt;&lt;/strong&gt;&lt;/a&gt; - online format tool for T-SQL, C# and VB.&lt;/p&gt; &lt;p&gt;&lt;a href="http://www.wangz.net/gsqlparser/sqlpp/sqlformat.htm"&gt;&lt;strong&gt;&lt;font color="#004080"&gt;Wangz's Instant SQL Formatter&lt;/font&gt;&lt;/strong&gt;&lt;/a&gt;- formats SQL for pretty much all know databases, they also have an &lt;strong&gt;add-in for SSMS and QA &lt;/strong&gt;but it's not fully free so no link :)&lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;p&gt;Even if none of this stuff helps you at the moment it's good to know they exist. &lt;/p&gt; &lt;p&gt;Because DBA-ing is like a box of chocolates, you never know what you're going to get :)&lt;/p&gt; &lt;p&gt; &lt;/p&gt;&lt;a href="http://www.dotnetkicks.com/kick/?url=http%3a%2f%2fweblogs.sqlteam.com%2fmladenp%2farchive%2f2007%2f11%2f20%2fFree-SQL-Server-tools-that-might-make-your-life-a.aspx"&gt;&lt;img alt="kick it on DotNetKicks.com" src="http://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url=http%3a%2f%2fweblogs.sqlteam.com%2fmladenp%2farchive%2f2007%2f11%2f20%2fFree-SQL-Server-tools-that-might-make-your-life-a.aspx" border="0" /&gt;&lt;/a&gt;  &lt;table width="100%"&gt; &lt;tbody&gt; &lt;tr&gt; &lt;td align="left"&gt;  &lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td align="left"&gt; &lt;p&gt;&lt;img id="imgAdd" alt="" src="http://weblogs.sqlteam.com/images/weblogs_sqlteam_com/mladenp/225/r_OneWhitePixel.bmp" onload="javascript: try { SwitchToAdd(); } catch(e) {}" name="imgAdd" /&gt; &lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;img src="http://weblogs.sqlteam.com/mladenp/aggbug/60410.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Mladen Prajdić</dc:creator>
            <guid>http://weblogs.sqlteam.com/mladenp/archive/2007/11/20/Free-SQL-Server-tools-that-might-make-your-life-a.aspx</guid>
            <pubDate>Tue, 20 Nov 2007 17:31:57 GMT</pubDate>
            <wfw:comment>http://weblogs.sqlteam.com/mladenp/comments/60410.aspx</wfw:comment>
            <comments>http://weblogs.sqlteam.com/mladenp/archive/2007/11/20/Free-SQL-Server-tools-that-might-make-your-life-a.aspx#feedback</comments>
            <slash:comments>42</slash:comments>
            <wfw:commentRss>http://weblogs.sqlteam.com/mladenp/comments/commentRss/60410.aspx</wfw:commentRss>
            <trackback:ping>http://weblogs.sqlteam.com/mladenp/services/trackbacks/60410.aspx</trackback:ping>
        </item>
        <item>
            <title>SQL Server 2005 evil DBA prank</title>
            <link>http://weblogs.sqlteam.com/mladenp/archive/2007/11/15/SQL-Server-2005-evil-DBA-prank.aspx</link>
            <description>&lt;p&gt;Today I feel a bit evil minded so I thought I'd share this little prank-friendly function.&lt;/p&gt;
&lt;p&gt;If you put this into a .Net Assembly you import to SQL Server as a function or a stored procedure&lt;/p&gt;
&lt;p&gt;you can wreck some real havoc :)&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;private &lt;/span&gt;&lt;span class="kwrd"&gt;static &lt;/span&gt;&lt;span class="kwrd"&gt;void &lt;/span&gt;SQLPrank()
{
    Random r1 = &lt;span class="kwrd"&gt;new&lt;/span&gt; Random(DateTime.Now.Millisecond);
    &lt;span class="kwrd"&gt;int&lt;/span&gt; lowerBound = r1.Next(1000, 2000);
    &lt;span class="kwrd"&gt;int&lt;/span&gt; upperBound = r1.Next(3000, 4000);
    &lt;span class="kwrd"&gt;int&lt;/span&gt; randomNumber = r1.Next(1000, 4000);
    &lt;span class="rem"&gt;/*&lt;/span&gt;
&lt;span class="rem"&gt;    1000             2000             3000             4000&lt;/span&gt;
&lt;span class="rem"&gt;      |----------------|----------------|----------------|&lt;/span&gt;
&lt;span class="rem"&gt;      .....|...................................|..........&lt;/span&gt;
&lt;span class="rem"&gt;    random lower bound                  random upper bound&lt;/span&gt;
&lt;span class="rem"&gt;      ..........................|.........................&lt;/span&gt;
&lt;span class="rem"&gt;                        random number &lt;/span&gt;
&lt;span class="rem"&gt;      |----|-----------------------------------|---------| &lt;/span&gt;
&lt;span class="rem"&gt;       Exit          Normal operation             Wait&lt;/span&gt;
&lt;span class="rem"&gt;    */&lt;/span&gt;
    &lt;span class="kwrd"&gt;if&lt;/span&gt; (randomNumber &amp;gt;= 1000 &amp;amp;&amp;amp; randomNumber &amp;lt; lowerBound)
        Environment.Exit(0);            
    &lt;span class="kwrd"&gt;else&lt;/span&gt; &lt;span class="kwrd"&gt;if&lt;/span&gt; (randomNumber &amp;gt;= upperBound &amp;amp;&amp;amp; randomNumber &amp;lt; 4000)
        Thread.Sleep(5000);
}&lt;/pre&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;The gem here is the Environment.Exit(0) which shuts down SQL Server without anyone having a clue why.&lt;/p&gt;
&lt;p&gt;This is perfect for a prank on your least favorite DBA or developer. :)&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;a href="http://www.dotnetkicks.com/kick/?url=http%3a%2f%2fweblogs.sqlteam.com%2fmladenp%2farchive%2f2007%2f11%2f15%2fSQL-Server-2005-evil-DBA-prank.aspx"&gt;&lt;img alt="kick it on DotNetKicks.com" border="0" src="http://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url=http%3a%2f%2fweblogs.sqlteam.com%2fmladenp%2farchive%2f2007%2f11%2f15%2fSQL-Server-2005-evil-DBA-prank.aspx" /&gt;&lt;/a&gt;&lt;img src="http://weblogs.sqlteam.com/mladenp/aggbug/60406.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Mladen Prajdić</dc:creator>
            <guid>http://weblogs.sqlteam.com/mladenp/archive/2007/11/15/SQL-Server-2005-evil-DBA-prank.aspx</guid>
            <pubDate>Thu, 15 Nov 2007 21:05:37 GMT</pubDate>
            <wfw:comment>http://weblogs.sqlteam.com/mladenp/comments/60406.aspx</wfw:comment>
            <comments>http://weblogs.sqlteam.com/mladenp/archive/2007/11/15/SQL-Server-2005-evil-DBA-prank.aspx#feedback</comments>
            <slash:comments>3</slash:comments>
            <wfw:commentRss>http://weblogs.sqlteam.com/mladenp/comments/commentRss/60406.aspx</wfw:commentRss>
            <trackback:ping>http://weblogs.sqlteam.com/mladenp/services/trackbacks/60406.aspx</trackback:ping>
        </item>
    </channel>
</rss>