Solved

Debugging a SQL Server Script using Visual Studio?

Posted on 2015-02-24
6
105 Views
Last Modified: 2015-02-25
Is it possible to debug a SQL Server script while running a VB.Net application in debug mode? If so, how is this done because I really need to debug a SQL script and just not sure what the best way is to do it!

Thanks!
0
Comment
Question by:BlakeMcKenna
  • 3
  • 3
6 Comments
 
LVL 63

Expert Comment

by:Fernando Soto
ID: 40629811
Hi BlakeMcKenna;

See this Microsoft Documentation.

Debugging Transact-SQL Database Objects
0
 

Author Comment

by:BlakeMcKenna
ID: 40630590
Fernando,

This is what I've been looking for, however, I'm a little confused as to whether it can be debugged while the application is running. What I'm trying to accomplish is that when my app is running and at the point of executing the Stored Procedure, which is what I want to debug, I want the GUI to go into debug mode at that point right into the SP. That's where I'm at right now. Also, I'm using VS 2013 Professional edition and the above link uses verbage that I don't see.  For example, it says to right-click on the object within the Database, in my case the SP and select "Step Into" <object>. That isn't part of any popup menu that I see.

Thanks!
0
 

Author Comment

by:BlakeMcKenna
ID: 40630661
Fernando,

When I tried to execute the SP for debug, I got an error message. See attached image. It had to do with permissions, however, when I went to look in the "System Stored Procedures" Folder, the SP listed was not present.
Screenshot.jpg
0
Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

 
LVL 63

Accepted Solution

by:
Fernando Soto earned 500 total points
ID: 40631659
Hi BlakeMcKenna;

I had a hard time finding out how to enable SQL Stored Procedure in Visual Studio 2013 seeming it changed since I used it in earllyer version.

1. In Solution Explorer right click on the Project Name, NOT Solution name, and select Properties from context window.
2. In the Properties window select the Debug tab at the left of the window.
3. At the bottom of the window make sure the Enable SQL Server Debugging has a check mark on it.
4. From the Main Menu in Visual Studio click on View -> SQL Server Object Explorer.
5. If your SQL Server instance is not in the list of SQL Servers right click on the top node SQL Server and select Add SQL Server ... and use the SQL Server Login window to login to the missing server.
6. Select the server from the list and right click on it.
7. Click on Application Debugging.

At this point you will be able to set break points in the SQL Script and it will stop on the break point.
0
 

Author Closing Comment

by:BlakeMcKenna
ID: 40631742
Thank you Fernando...that is exactly what I have been looking for!
0
 
LVL 63

Expert Comment

by:Fernando Soto
ID: 40631770
Not a problem BlakeMcKenna; glad I was able to help.
0

Featured Post

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
In this article we will get to know that how can we recover deleted data if it happens accidently. We really can recover deleted rows if we know the time when data is deleted by using the transaction log.
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question