May 132012
 
The Mysterious "sp_" System Procedure Prefix

If you have been working with SQL Server for a while you probably know that you should not select names for your stored procedures that start with the three characters “sp_”.

Today I would like to take a closer look at all the myths and facts around this prefix. All examples in this article have been tested on SQL 2008R2 and on SQL 2012.

Apr 292012
 
The Unloved Backward Scan

When a query requires rows to be sorted, either directly requested with an [tt]ORDER BY[/tt] clause or because one of the iterators requires it, SQL Server has two options to guarantee that order. The obvious one is to utilize a sort iterator. If the data comes from an index (clustered or covering), SQL Server can also use an “Ordered Scan” of the data. Depending on the requested sort direction, such an ordered scan can be either forward or backward.

This would hardly be worth an article, if there wasn’t the peculiarity that SQL Server obviously does not like the idea of having to execute an ordered scan that is directed backwards.

Apr 222012
 
TOP N Sort - A Little Bit of Sorting

Sorting is one of the most often used functions in SQL Server. It is used when creating indexes. It allows us to retrieve data in a particular order. It also is used to filter out repeated rows in the context of a DISTINCT request. The SQL Server Team spent a lot of effort optimizing the sort algorithms to give the best possible performance in each context. This blog post looks at the TOP N Sort optimization.

Bad Behavior has blocked 174 access attempts in the last 7 days.