Wednesday, 17 November 2010

First Look at SQL Server Denali (Part 1 – Debugging)

This is a first look at some of the new features in SQL Server “Denali” (which will most likely become SQL Server 2011).

SQL Server “Denali” CTP1 is available for download from the Microsoft Download Center here.  The press release is here.

image

Today, I’ll be focussing on the improved debugging functionality in SQL Server Management Studio. Following is a straightforward query to loop through the SalesOrderDetail table 10 times and add one to the UnitPrice each time (I’m not too concerned in this example with why you would want to do that!). I have filtered the query to rows which have a SalesOrderDetailID of less than 10.

image

We can now add a breakpoint on the UPDATE statement.

image

So far, nothing has changed, but if you right-click the breakpoint you can add limit the breakpoint by Location, Condition, and Hit Count, specify a filter for certain processes and specify what to do when a breakpoint is hit.

image

In this example, I have added a Condition of 2’">2’">2’">‘@counter>2’ and a HitCount of 2. Therefore the break should occur the second time the @counter value is over 2. If we run the code in debug mode we can see (after moving the panes around to get it in one screen capture) that value of @counter is 4 which is indeed the second time it has hit a value over 2.

image

This is a very straightforward example, but you can see that this makes the ability to use breakpoints much more powerful and therefore much more useful.

No comments: