0% found this document useful (0 votes)
4 views7 pages

107 Debugging SQL Server Stored Procedures

This document is a video tutorial on debugging SQL Server stored procedures using SQL Server Management Studio (SSMS). It covers setting up the debugger, executing stored procedures, and utilizing various debugging tools such as the Locals, Watch, and Call Stack windows. Additionally, it explains how to set breakpoints and conditional breakpoints for effective debugging.

Uploaded by

realayoola007
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views7 pages

107 Debugging SQL Server Stored Procedures

This document is a video tutorial on debugging SQL Server stored procedures using SQL Server Management Studio (SSMS). It covers setting up the debugger, executing stored procedures, and utilizing various debugging tools such as the Locals, Watch, and Call Stack windows. Additionally, it explains how to set breakpoints and conditional breakpoints for effective debugging.

Uploaded by

realayoola007
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

3/12/2023 Sql server, .

net and c# video tutorial: Debugging sql server stored procedures


The Wayback Machine - [Link]

Sql server, .net and c# video tutorial


Free C#, .Net and Sql server video tutorial for beginners and intermediate programmers.

Support us .Net Basics C# SQL [Link] Aarvi MVC Slides C# Programs Subscribe Download

Debugging sql server stored procedures

Suggested Videos
Part 104 - Difference between cube and rollup in SQL Server
Part 105 - Grouping function in SQL Server
Part 106 - Grouping_Id function in SQL Server

Pragim Technologies - Best software


training and placements in marathahalli,
bangalore. For further details please call
09945699393.

Complete Tutorials
How to become a full stack web
developer

Cloud computing complete tutorial

In this video we will discuss how to debug stored procedures in SQL Server. Healthy food for healthy mind and
body

JavaScript tutorial

Bootstrap tutorial

Angular tutorial for beginners

Angular 5 Tutorial for beginners

[Link] 1/7
3/12/2023 Sql server, .net and c# video tutorial: Debugging sql server stored procedures

Important Videos
The Gift of Education

Web application for your business

How to become .NET developer

Resources available to help you

Dot Net Video Tutorials


Blazor tutorial

C tutorial

[Link] Core Tutorial


Setting up the Debugger in SSMS : If you have connected to SQL Server using (local)
or . (period), and when you start the debugger you will get the following error [Link] Core Razor Pages Tutorial
Unable to start T-SQL Debugging. Could not connect to computer.
Angular 6 Tutorial

Angular CRUD Tutorial

Angular CLI Tutorial

Angular 2 Tutorial

Design Patterns

SOLID Principles

[Link] Web API


To fix this error, use the computer name to connect to the SQL Server instead of using
(local) or . Bootstrap

AngularJS Tutorial

jQuery Tutorial

JavaScript with [Link] Tutorial

JavaScript Tutorial

Charts Tutorial

LINQ

LINQ to SQL

LINQ to XML

Entity Framework

WCF
For the examples in this video we will be using the following stored procedure.
Create procedure spPrintEvenNumbers [Link] Web Services
@Target int
as Dot Net Basics
Begin
C#
Declare @StartNumber int
Set @StartNumber = 1 SQL Server

while(@StartNumber < @Target) [Link]


Begin
If(@StartNumber%2 = 0) [Link]
Begin
Print @StartNumber GridView
End
[Link] MVC
Set @StartNumber = @StartNumber + 1
End Visual Studio Tips and Tricks
Print 'Finished printing even numbers till ' + RTRIM(@Target)
End Dot Net Interview Questions

Connect to SQL Server using your computer name, and then execute the above code to Slides
[Link] 2/7
3/12/2023 Sql server, .net and c# video tutorial: Debugging sql server stored procedures
create the stored procedure. At this point, open a New Query window. Copy and paste Entity Framework
the following T-SQL code to execute the stored procedure.
WCF
DECLARE @TargetNumber INT
SET @TargetNumber = 10 [Link] Web Services
EXECUTE spPrintEvenNumbers @TargetNumber
Dot Net Basics
Print 'Done'
C#
Starting the Debugger in SSMS : There are 2 ways to start the debugger
1. In SSMS, click on the Debug Menu and select Start Debugging SQL Server

[Link]

[Link]

GridView

[Link] MVC

Visual Studio Tips and Tricks

Java Video Tutorials


Part 1 : Video | Text | Slides

Part 2 : Video | Text | Slides


2. Use the keyboard shortcut ALT + F5
Part 3 : Video | Text | Slides
At this point you should have the debugger running. The line that is about to be
executed is marked with an yellow arrow Interview Questions
C#

SQL Server

Written Test

Step Over, Step into and Step Out in SSMS : You can find the keyboard shortcuts in the
Debug menu in SSMS.

Let us understand what Step Over, Step into and Step Out does when debugging the
following piece of code

1. There is no difference when you STEP INTO (F11) or STEP OVER (F10) the code on
LINE 2

2. On LINE 3, we are calling a Stored Procedure. On this statement if we press F10


(STEP OVER), it won't give us the opportunity to debug the stored procedure code. To
be able to debug the stored procedure code you will have to STEP INTO it by pressing

[Link] 3/7
3/12/2023 Sql server, .net and c# video tutorial: Debugging sql server stored procedures
F11.

3. If the debugger is in the stored procedure, and you don't want to debug line by line
with in that stored procedure, you can STEP OUT of it by pressing SHIFT + F11. When
you do this, the debugger completes the execution of the stored procedure and waits on
the next line in the main query, i.e on LINE 4 in this example.

To stop debugging : There are 2 ways to stop debugging


1. In SSMS, click on the Debug Menu and select Stop Debugging
2. Use the keyboard shortcut SHIFT + F5

Show Next Statement shows the next statement that the debugger is about to execute.
Run to Cursor command executes all the statements in a batch up to the current cursor
position

Locals Window in SSMS : Displays the current values of variables and parameters

If you cannot see the locals window or if you have closed it and if you want to open it,
you can do so using the following menu option. Locals window is only available if you
are in DEBUG mode.

Watch Window in SSMS : Just like Locals window, Watch window is used to watch the
values of variables. You can add and remove variables from the watch window. To add
a variable to the Watch Window, right click on the variable and select "Add Watch"
option from the context menu.

[Link] 4/7
3/12/2023 Sql server, .net and c# video tutorial: Debugging sql server stored procedures
Call Stack Window in SSMS : Allows you to navigate up and down the call stack to
see what values your application is storing at different levels. It's an invaluable tool for
determining why your code is doing what it's doing.

Immediate Window in SSMS : Very helpful during debugging to evaluate expressions,


and print variable values. To clear immediate window type >cls and press enter.

Breakpoints in SSMS : There are 2 ways to set a breakpoint in SSMS.


1. By clicking on the grey margin on the left hand side in SSMS (to remove click again)
2. By pressing F9 (to remove press F9 again)

Enable, Disable or Delete all breakpoints : There are 2 ways to Enable, Disable or
Delete all breakpoints

1. From the Debug menu

2. From the Breakpoints window. To view Breakpoints window select Debug =>
Windows => Breakpoints or use the keyboard shortcut ALT + CTRL + B

Conditional Breakpoint : Conditional Breakpoints are hit only when the specified
condition is met. These are extremely useful when you have some kind of a loop and
you want to break, only when the loop variable has a specific value (For example loop
varible = 100).

How to set a conditional break point in SSMS :


1. Right click on the Breakpoint and select Condition from the context menu

[Link] 5/7
3/12/2023 Sql server, .net and c# video tutorial: Debugging sql server stored procedures

2. In the Breakpoint window specify the condition

3 comments:

chandra sekhar sharma MCA September 29, 2015 at 3:58 AM


Hi Venkat Sir,
Thank you so much for keep posting videos on [Link] you please tell me how to
pass mutiple values as parameters to a stored procedure(say 1000).This is one my
interview questions.
Thanks in advance
Reply

chandra sekhar sharma MCA September 29, 2015 at 4:02 AM


Hi Sir,
Thank you so much for keep on posting the videos on [Link] you please record
the video for passing multiple values to stored procedure(say 1000).This is one of my
interview questions.
Thnaks in advance
Reply

Replies

Unknown November 1, 2015 at 4:22 PM


I am not exactly sure but by referring previous videos i think it can be done by
passing table valued variable to procedure.

create type tableValuedVariable as table


(x int,
y int
)

create procedure SP_XYAB


@tv tableValuedVariable readonly
as
begin
select * into bckUp from @tv
-- insert into select * from @tv
end

[Link] 6/7
3/12/2023 Sql server, .net and c# video tutorial: Debugging sql server stored procedures
declare @tvV1 tableValuedVariable
insert into @tvV1 values (1,2)
-- insert as many you want
execute SP_XYAB @tvV1

Reply

It would be great if you can help share these free resources

Newer Post Home Older Post

Subscribe to: Post Comments (Atom)

Powered by Blogger.

[Link] 7/7

You might also like