Getting Started with Adobe After Effects - Part 6: Motion Blur


Upload Image Close it
Select File

Towards the innovative SQL ideas
Browse by Tags · View All
ms sql server 119
ms sql 118
sql server 116
sql 115
database 102
tsql 81
#SQL Server 78
t-sql 75
#sql 71
sql server general 67

Archive · View All
April 2011 14
July 2011 12
May 2011 12
August 2011 11
June 2011 10
September 2011 8
December 2011 6
November 2011 6
June 2013 5
April 2013 5

SQL Server 2008 - TSQL Debugger for Stored Procedure

Aug 17 2011 12:00AM by Paresh Prajapati   

Problem:
When we run in the issue of something wrong or incorrect with stored procedure and suppose the stored procedure has 1000 lines long and very complex code for custom logic inside it, what you do?

Then for above such issue, we put the SQL trace and get the procedure parameters and manually run the stored procedure and put the print statement inside SP to watch parameter track. Or sometime we run the each block manually one by one sequentially to get the issue point.

Solution:
After releasing of SQL Server 2008, We have one more option or feature to get it easily done for the issue. That is "TSQL Debugger".

With this feature we can debug the stored procedure and can track or watch all the thing inside logic. Let's look on some shots which i have captured during debugging of the stored procedure. Create this procedure.

Example:
CREATE PROCEDURE Procdebug @in  INT,
                           @out INT out
AS
  BEGIN
      IF ( @in IS NULL )
        SET @in = 0

      WHILE ( @in < = 100 )
        BEGIN
            SET @out = @in
            SET @in = @in + 10

            PRINT CONVERT(VARCHAR, @in) + ' - ' + CONVERT(VARCHAR, @out)
        END
  END

GO 

DECLARE @out INT
EXEC Procdebug 1,@out OUTPUT
SELECT @out
After creating stored procedure , select the second script to debug it. After selecting press F11, screen will open sored procedure in debug mode as below.



You can see in the image as how can we add Watch of the variables while debugging. From below image you have idea of how values are tracked for variables.



Finally with completion of debugging the stored procedure the last output variable selected.



Happy debugging!

Tags: sql, sql server 2005, tsql, sql server, ms sql, ms sql server, variable, SET, sql server denali, #SQL Server, mssql, #sql, sql server 2011, database, sql server general, SQL Scripts, SQL new features, debug,


Paresh Prajapati
6 · 22% · 7044
10
 
0
Lifesaver
 
0
Refreshed
 
0
Learned
 
0
Incorrect



Submit

10  Comments  

  • The T-SQL debugger is my favorite single new feature of SQL Server, and I use it constantly.

    You don't have to watch a variable in order to see it's value throughout execution, you can check the "Locals" window. "Watching" a variable only puts it into a separate window/pane to make it easier to find.

    My only recommendation for improvement is that you can't watch or see the values stored within a cursor, temp table or table-typed variable within the debugger.

    commented on Sep 3 2011 8:56AM
    Marc Jellinek
    97 · 2% · 545
  • I share the same feeling as marc

    commented on Sep 3 2011 10:00AM
    Jacob Sebastian
    1 · 100% · 32002
  • I am afraid that this is not quite accurate. The T-SQL Debugger is not new to SQL 2008, but instead has been around at least since SQL Server 2000, and even then one had the advanced ability to go down into a trigger to debug it. You can read all about the T-SQL Debugger in my various posts:

    I am also currently running a series on the Debugger enhancements made in the upcoming release of Microsoft SQL Server - SQL11 ("Denali").

    commented on Sep 27 2011 12:29PM
    Nakul Vachhrajani
    4 · 33% · 10564
  • When I try to debug sql server SP 2008 R2 getting following error In Management Studio 2008 after setting a breakpoint on any piece of T-SQL and presssing debug button:

    TITLE: Microsoft SQL Server Management Studio

    Failed to start debugger


    ADDITIONAL INFORMATION:

    Data is Null. This method or property cannot be called on Null values. (System.Data)


    BUTTONS:

    OK Microsoft SQL Server Management Studio

    Unable to start program 'MSSQL:://(local)/master/sys/=0'.


    Any solution to this problem

    commented on Oct 5 2011 8:31AM
    Hima
    31 · 6% · 1776
  • Hi Hima,

    If you are using windows authentication then check the server role sysadmin assigned to it. You can perform it with EXEC sp_addsrvrolemember 'Domain\Name', 'sysadmin'

    Please check this issue in SQL Server Forums , This might help you, http://social.msdn.microsoft.com/Forums/en-US/sqltools/thread/e3a212d7-9e32-4b37-ae3a-c0010cb23858/

    commented on Oct 7 2011 1:54AM
    Paresh Prajapati
    6 · 22% · 7044
  • Thanks Paresh. Installing latest SP2 helped me .

    commented on Oct 7 2011 2:04AM
    Hima
    31 · 6% · 1776
  • Nakul,

    I have SS2008R2 SP2 Express Edition. The Debug menu is there but it will not start and this confirms what you say.

    I also have SS2005 SP4 Standard Edition. But this Debug menu item is not present and Paresh's suggestion to press F11 does nothing. And yet you say it's been around since SS2000.

    commented on Nov 14 2012 6:27AM
    dishdy
    17 · 10% · 3262
  • Dishdy: The SQL Server debugger in versions prior to 2008 was much harder to use and set up. It really required the full version of Visual Studio. The Microsoft Knowledge Base will give you the details.

    SQL Server 2008 Management Studio Express does support debugging: http://social.msdn.microsoft.com/Forums/en-US/sqlexpress/thread/7a933a9f-f06a-4817-83bf-d4bd2759f7a8. Rather than debugging from the Debug menu, highlight what you want to debug and hit F11. It will start to execute within the debugger.

    commented on Nov 14 2012 9:46AM
    Marc Jellinek
    97 · 2% · 545
  • Got SSMS 2008 R2 Express to debug.

    Logging in with sa would not work. But then I created my domain user in SSMS, put him in the sysadmin group and logged with Windows Authentication. Debug then works like a charm

    commented on Nov 14 2012 11:23AM
    dishdy
    17 · 10% · 3262
  • Yes, Express editions do not support debugging (officially). In some corporate IT configurations, there may still be a couple of challenges related to Firewall settings and proper registration of the Visual Studio environment that might impact the workings of the debugger (you can refer some of my earlier posts, mentioned above, for the same).

    commented on Nov 14 2012 11:28AM
    Nakul Vachhrajani
    4 · 33% · 10564

Your Comment


Sign Up or Login to post a comment.

"SQL Server 2008 - TSQL Debugger for Stored Procedure" rated 5 out of 5 by 10 readers
SQL Server 2008 - TSQL Debugger for Stored Procedure , 5.0 out of 5 based on 10 ratings
    Copyright © Rivera Informatic Private Ltd Contact us      Privacy Policy      Terms of use      Report Abuse      Advertising      [ZULU1097]