0

I have Visual Studio .Net project which uses ADO connection to call stored procedure of SQL Server database.

It is possible to set a breakpoing at stored procedure and debug it. I have local SQL Server and SQL Enterprise Edition installed.

2
  • are you talking about debugging the actual stored procedure itself? and is the stored procedure managed code or TSQL? Commented Dec 8, 2009 at 19:56
  • 2 agent I think it is TSQL. It is stored on DB side ALTER procedure [aaa].[my_Proc] begin ... Commented Dec 8, 2009 at 20:02

5 Answers 5

1

AFAIK, and if you are talking about an actual t-sql stored procedure, Your best bet will be:

  1. figure out what parameters you are passing into the stored procedure when (if?) it causes problems
  2. Extract the actual SQL code from the body of the stored procedure and copy that into a new query analyzer window,
  3. Run that script with the values from #1.
Sign up to request clarification or add additional context in comments.

3 Comments

the problem is that one SP is called when it shouldn't be. I need to 'catch' who's calling it
Ahhh, well yes you can put a breakpoint in your code and do it that way. Do you have an idea of where in the code the call might be coming from? If not, you may need to do a lot of F10 work, but you'll find it eventually. It may help to keep SQL Server Profiler open and running as you go.
Sure I know this way. But my question was if there is debug mode in SQL server where I can put breakpoint using SSMS and wait until some application triggers it
1

There are a couple options i have heard of for debugging stored procs- eg: Direct Database Debugging.

here is a link from a good article i found explaining some of these: Stored Proc Debugging Methods

Comments

1

You can debug CLR procedures and functions from VS, see Debugging SQL

Transact-SQL is a different story, it needs special configuration steps and can be debugged from a special tool, see Using the Transact-SQL Debugger.

Comments

1

Use the SQL Server Profiler (under Tools menu in SQL Server Management Studio) to see the exact calls being sent from ADO to your database procedures. Then you can figure out where the problem is and start debugging, whether in SSMS or Visual Studio.

Comments

0

I would strongly suggest that you take a look at the built in tooling in SQL management studio.

i have written a pretty detailed blog post about it here:

http://www.diaryofaninja.com/blog/2010/11/23/debugging-sql-queries-function-amp-stored-procedures-with-sql-management-studio

basically the gist of it is that you enter you sql query to execute your stored procedure, and instead of pressing F5 or hitting the exclamation, you hit the play button and use F10 and F11 to step through and step into your stored procs.

very very handy - and no one seems to use it.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.