Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

SQL debugging question

Posted on 2009-07-10
4
Medium Priority
?
191 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 2000 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

New benefit for Premium Members - Upgrade now!

Ready to get started with anonymous questions today? It's easy! Learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I am showing a way to read/import the excel data in table using SQL server 2005... Suppose there is an Excel file "Book1" at location "C:\temp" with column "First Name" and "Last Name". Now to import this Excel data into the table, we will use…
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…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…

722 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