Solved

SQL debugging question

Posted on 2009-07-10
4
187 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 75

Expert Comment

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

Expert Comment

by:pssandhu
ID: 24824115
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
ID: 24824128
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
ID: 24824167
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

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

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…
So every once in a while at work I am asked to export data from one table and insert it into another on a different server.  I hate doing this.  There's so many different tables and data types.  Some column data needs quoted and some doesn't.  What …
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

752 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