Solved

SQL debugging question

Posted on 2009-07-10
4
186 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
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

NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

Question has a verified solution.

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

INTRODUCTION: While tying your database objects into builds and your enterprise source control system takes a third-party product (like Visual Studio Database Edition or Red-Gate's SQL Source Control), you can achieve some protection using a sing…
In this article I will describe the Backup & Restore method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
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…

828 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