Smart questions
Smart answers
Smart people
Join Tek-Tips Forums
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Member Login




Remember Me
Forgot Password?
Join Us!

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips now!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

Join Tek-Tips
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.
Jobs from Indeed

Link To This Forum!

Partner Button
Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

View variable values in SQL stored procedureHelpful Member!(2) 

Webkins (Programmer) (OP)
28 Mar 12 16:57
Hello, I have a stored procedure in SQL2K which contains many @variables. I would like to debug my stored procedure and see the actual contents of each variable. Is it possible to step through the code or to see the contents of each variable similar as in VB/VBA ?

Thank you...
Helpful Member!  gmmastros (Programmer)
28 Mar 12 17:01
I've never really had much luck debugging/stepping through TSQL code.  Instead, I usually print or select the variables, like this....


CODE

Select @VariableName

Print @VariableName

You can even hard code values so you can check the variable values at different points within the code.  Ex:

CODE


Select 'Before Query 1',@Variable

-- Big ole query here

Select 'After Query 1',@Variable

Of course, you'll need to remove (or comment) these lines prior to declaring your code "done".

-George
Microsoft SQL Server MVP
My Blogs
SQLCop
twitter
"The great things about standards is that there are so many to choose from." - Fortune Cookie Wisdom

JoeAtWork (Programmer)
29 Mar 12 0:08
As per my comment in your other thread, this is why I would leave logic handling in a higher level application level and leave stored procedures for simply retrieving the data you need.
 
TysonLPrice (Programmer)
30 Mar 12 6:28
There is a debugger you can step through code with and see variables but it can be a pain to set up.  To me it was worth the effort.  I had to coordinate setting it up with the DBA group (I'm in applications).  It's been quite a while but this link jogged my memory on some of the thinks we needed to do.

http://www.codeproject.com/Articles/20140/SQL-Stored-Procedure-Debugging-from-SQL-Query-Anal

Then MS took it away in 2005 and I believe it is coming back in 2008.  MS VS 2010 has a stored procedure debuuger that is pretty cool and I believe the software is free.

In all the scenarios the DBA group here keeps it in the deveopement environment becuase of the access needed to run them.
 
Helpful Member!  TysonLPrice (Programmer)
30 Mar 12 6:47
This link is for Visual Studio 2005 but it works the same way in VS 2010.

http://www.codeproject.com/Articles/30573/SQL-Stored-Procedure-Debugging-Using-Visual-Studio

Google using "Visual Studio 2010 download free" and take your pick.
 

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Back To Forum

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close