Unix Technical Forum

debugging stored procedures

This is a discussion on debugging stored procedures within the SQL Server forums, part of the Microsoft SQL Server category; --> Hello, I am doing a lot of work with stored procedures at work now and am wondering if there ...


Go Back   Unix Technical Forum > Database Server Software > Microsoft SQL Server > SQL Server

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-29-2008, 06:31 AM
Little PussyCat
 
Posts: n/a
Default debugging stored procedures


Hello,

I am doing a lot of work with stored procedures at work now and am wondering
if there is a way that I can step through the code line by line and set
breakpoints on it like I do in VB/VBA to test variables/parameters.

Regards,

Jayne
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 02-29-2008, 06:31 AM
Hugo Kornelis
 
Posts: n/a
Default Re: debugging stored procedures

On Tue, 08 Mar 2005 21:38:46 +0000, Little PussyCat wrote:

>I am doing a lot of work with stored procedures at work now and am wondering
>if there is a way that I can step through the code line by line and set
>breakpoints on it like I do in VB/VBA to test variables/parameters.


Hi Jayne,

In Query Analyzer, hit F8 to bring up the object browser. Find the
stored procedure, right-click it and select "Debug".

Best, Hugo
--

(Remove _NO_ and _SPAM_ to get my e-mail address)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 02-29-2008, 06:31 AM
Erland Sommarskog
 
Posts: n/a
Default Re: debugging stored procedures

Hugo Kornelis (hugo@pe_NO_rFact.in_SPAM_fo) writes:
> On Tue, 08 Mar 2005 21:38:46 +0000, Little PussyCat wrote:
>>I am doing a lot of work with stored procedures at work now and am
>>wondering if there is a way that I can step through the code line by
>>line and set breakpoints on it like I do in VB/VBA to test
>>variables/parameters.

>
> In Query Analyzer, hit F8 to bring up the object browser. Find the
> stored procedure, right-click it and select "Debug".


That's the theory.

In practice it appears that there is always something that prevents it
from working. To start with SQL Server must be running from a domain
account, and not local server. If you have Windows XP SP2 on the client,
you need at least 8.00.944 or the beta of SQL 2000 SP4, and you must
apply it on server and client. On top of that you must open port 135
in Windows firewall for the SQL box. (Do NOT open this port generally.)

And when all is done, you sysadm may get the idea that the Windows users
under which SQL Server runs is not permitted access to the workstations.
This how the last attempt ended in our shop.

I should add if you run SQL Server on your own machine, debugging
usually works.

--
Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 02-29-2008, 06:31 AM
Miss Livvy
 
Posts: n/a
Default Re: debugging stored procedures

You can also step into T-SQL stored procs from the VB or .NET development
environment. But personally, I have not found stepping into stored procs to
be all that useful since I could not see a way to examine the result sets of
queries. I have found using SQL profiler to be extremely useful for seeing
what parameters the calling app is passing in and which statements are
getting executed within the procedure. However, I think you need SA rights
to run profiler. To examine the result sets of queries, I usually just run
the guts of the procedure in Query Analyzer and use select statements to
dump the intermediate results. .


"Little PussyCat" <SPAMSPAM@NOSPAM.com> wrote in message
news:ccm1g2-n1c.ln1@tiger.sphynx...
>
> Hello,
>
> I am doing a lot of work with stored procedures at work now and am

wondering
> if there is a way that I can step through the code line by line and set
> breakpoints on it like I do in VB/VBA to test variables/parameters.
>
> Regards,
>
> Jayne



Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 02-29-2008, 06:32 AM
Erland Sommarskog
 
Posts: n/a
Default Re: debugging stored procedures

Miss Livvy (XeveryidiwantistakenX@yahoo.com) writes:
> You can also step into T-SQL stored procs from the VB or .NET
> development environment. But personally, I have not found stepping into
> stored procs to be all that useful since I could not see a way to
> examine the result sets of queries.


Yeah, I agree. Occassionally if a I have procedure with lot of procedural
logic, single-stepping through it can be helpful. The same is true if
want to look at the values of some variables.

But often I find too much hassle to start the debugger, so I rather
modify the procedure with some debug SELECT:s in strategic places.

Also, if your procedure raises an error and you want to debug that
happens after the error, the debugger does not appear to be very
co-operative.

--
Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 09:42 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com