SQL Server administration and T-SQL development, Web Programming with ASP.NET, HTML5 and Javascript, Windows Phone 8 app development, SAP Smartforms and ABAP Programming, Windows 7, Visual Studio and MS Office software
Development resources, articles, tutorials, code samples, tools and downloads for ASP.Net, SQL Server, Reporting Services, T-SQL, Windows, AWS, SAP HANA and ABAP

How to Debug Stored Procedure in SQL Server 2008

Create a simple SQL stored procedure in SQL Server 2008 database.
Just to make a short introduction for how to debug stored procedure in SQL Server 2008, I code the below t-sql code and execute it to create stored procedure in sample SQL Server database.

CREATE Procedure spDebugStoredProcedure
 @i int

While @i < 10
 If @i = 3
  print 'Three'
  print @i

 set @i = @i + 1

Then you can open a new Query Editor windows using Ctrl+N in SQL Server Management Studio.
Paste the following t-sql command which calls the sql stored procedure we have just created in SQL Server 2008 database.

EXEC spDebugStoredProcedure 1

If you press F5, or Execute button the SQL engine will execute the sql stored procedure code with given input parameter values and display the output.
But in order to debug stored procedure in SQL Server 2008, t-sql developers can use Debug menu within the SSMS screen.
Pressing F11 or F10 will activate the SQL Server Management Studio Debugging screens and processes.
In order to step into stored procedure t-sql codes, the sql developer can continue with F11 Step Into short-cut.
If you step into SQL stored procedure codes, a new query editor will be opened displaying the t-sql source scripts of the related stored procedure.

By clicking on the grey area on the left of the debugging screen, t-sql programmers can place breakpoint on the sql code lines they want.


Within the SQL Server 2008 SSMS, many debugging windows will be activated for more control and information to sql developers.
Locals, Watch 1, Call Stack, Breakpoints, Command Window, and Output sub-screens are those helper debugging screens while debugging stored procedure in SQL Server 2008.


SQL Server

SQL Server 2019 Installation
download SQL Server 2019
download SQL Server 2017
download SQL Server 2016
download SQL Server 2014
download SQL Server 2012
MacOS ve SQL Server 2019

Copyright © 2004 - 2021 Eralper YILMAZ. All rights reserved.