Solved

SQL debugging question

Posted on 2009-07-10
4
183 Views
Last Modified: 2012-05-07
I created a large SQL procedure.  I've found a few errors I need to correct.  Is there a way to step through line by line in SQL Server 2005.  If not, how can I debug line by line to see what is causing an error.  SQL Server Profiler?  Thanks!!!
0
Comment
Question by:jasonbrandt3
  • 2
4 Comments
 
LVL 75

Expert Comment

by:Aneesh Retnakaran
Comment Utility
sql 2005 wonrt support debugging feature. you have use print statements for each and every line
0
 
LVL 17

Expert Comment

by:pssandhu
Comment Utility
When you run the procedure you should be getting bunch of error messages in the result pane/message window below. It points on which line the error occured. You can go through that to look at the errors line by line.
P.
0
 

Author Comment

by:jasonbrandt3
Comment Utility
I'm using some cursors, I'm trying to figure out which record is causing a foreign key error, that's why I would like to step through.  So there is no way to step through the sql code?
0
 
LVL 17

Accepted Solution

by:
pssandhu earned 500 total points
Comment Utility
As aneesh adviced, you can do some print statment. When in the cursor executing statments (IN your Begin... End block) have print statment as the very first stament to print loop value, row number or something you can refere back to .. and when the error orccurs you know where it was terminated.
Eg,
BEGIN
Print  @LoopValue   --- Printing Values
Select .....
Insert INTO......
END
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

I've encountered valid database schemas that do not have a primary key.  For example, I use LogParser from Microsoft to push IIS logs into a SQL database table for processing and analysis.  However, occasionally due to user error or a scheduled task…
Introduction: When running hybrid database environments, you often need to query some data from a remote db of any type, while being connected to your MS SQL Server database. Problems start when you try to combine that with some "user input" pass…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

771 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now