Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 99365
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T00:22:25+00:00 2026-05-11T00:22:25+00:00

Because I am a newbie I am trying to log out any errors that

  • 0

Because I am a newbie I am trying to log out any errors that may occur with stored procedures I write. I understand Try/Catch in SQL 2005 and error_procedure(), ERROR_MESSAGE() and the other built in functions. What I can’t figure out how to do is capture what record caused the error on an update.

I could probably use a cursor and loop through and update a row at a time. Then in the loop set a value and report on that value. But that seems to defeat the purpose of using SQL.

Any ideas or pointer on where to research this issue greatly appreciated. I do not fully understand RowNumber() could I use that somehow? Kind of grasping at straws here.

cheers and thanks

Bob

I am using SQL 2005.

Edit

I really do not want to use transactions for most of this, as it is just for reporting purposes. So an example of what I am doing is:

/******************************************************************************    Now get update the table with the current worker.  That depends on the    current status of the loan. ******************************************************************************/  UPDATE #table SET currWorker = tblUser.UserLogonName       FROM tblUser             JOIN tblLoanInvolvement ON tblLoanInvolvement.invlUnderwriterDeptID = tblUser.userID              WHERE tblLoanInvolvement.LOANid = #table.loanid             AND #table.currstatus in('R_UW_Approved','R_Submitted to Underwriting')     UPDATE #table SET currWorker = tblUser.UserLogonName   FROM tblUser         JOIN tblLoanInvolvement ON tblLoanInvolvement.invlProcessorID  = tblUser.userID          WHERE tblLoanInvolvement.LOANid = #table.loanid         AND #table.currstatus in('R_UW Approved With Conditions','R_Loan Resubmitted','R_UW_Suspended','R_Submitted to Processing')    UPDATE #table SET currWorker = tblUser.UserLogonName   FROM tblUser         JOIN tblLoanInvolvement ON tblLoanInvolvement.invlCloserID = tblUser.userID          WHERE tblLoanInvolvement.LOANid = #table.loanid         AND #table.currstatus in('R_Docs Out','R_Ready to Close','R_Scheduled to Close and Fund','Scheduled To Close') 

So if one row does not update correctly I do not want to loose the whole thing. But it would be very handy to know the value of #table.loanid that caused the problem.

Thanks for your time.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T00:22:25+00:00Added an answer on May 11, 2026 at 12:22 am

    A try/catch block like this…

    BEGIN TRY     -- Your Code Goes Here -- END TRY BEGIN CATCH     SELECT          ERROR_NUMBER() AS ErrorNumber,         ERROR_SEVERITY() AS ErrorSeverity,         ERROR_STATE() AS ErrorState,         ERROR_PROCEDURE() AS ErrorProcedure,         ERROR_LINE() AS ErrorLine,         ERROR_MESSAGE() AS ErrorMessage END CATCH 

    …is going to help you locate the problem in your SQL code. If this was in a stored procedure you could also return the parameters (i.e. add a SELECT @RecordID AS [RecordID] to that list in the catch block). Moving forward though, if you are running into problems with the actual data I would encourage you to look at adding foreign keys and other constraints to protect the logical integrity of your database. Ideally at a minimum you cannot put data into the database which will break your stored procedures.

    EDIT

    Refering to you’re most recent edits, if you put the UPDATE inside a stored procedure and catch the error, then replace your update series with calls to that procedure the remaining updates would continue, and you could return/track/log the error within the SP’s catch block however you wished to.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 72k
  • Answers 73k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer Sounds like you're just looking for a join. Your query… May 11, 2026 at 1:51 pm
  • added an answer The simplest was is to simply catch the IOError exception… May 11, 2026 at 1:51 pm
  • added an answer You need to have a parameterless constructor and I believe… May 11, 2026 at 1:51 pm

Related Questions

No related questions found

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.