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 4039856
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T12:40:24+00:00 2026-05-20T12:40:24+00:00

I am trying to create a Trigger, that will update the History Table with

  • 0

I am trying to create a Trigger, that will update the History Table with Receipt Information.

My Source Table has a SourceID and a ReceiptID.

So when i Update Receipt table, i want to copy that record to the history table, but i first need to get the SourceID of the source that is being updated.

this is what i have now:

ALTER TRIGGER [dbo].[trg_ReceiptHistory] 
ON [dbo].[tblReceipt]
for UPDATE
AS 
begin try
INSERT INTO tblHistorySource(RecShipName, RecShipAddress, sourceID)
select t1.shippingName, t1.shippingAddress, t2.sourceID
from [DELETED] t1, tblSource t2
where t2.receiptID = t1.receiptID
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;
RAISERROR('Error in Source Hisotry Trigger' ,16,1)
ROLLBACK TRAN
END CATCH

when i try to do a simple update to the tblReceipt, i get the following error:

Msg 50000, Level 16, State 1, Procedure trg_ReceiptHistory, Line 24
Error in Source Hisotry Trigger
Msg 3609, Level 16, State 1, Line 1
The transaction ended in the trigger. The batch has been aborted.

Am I doing it wrong? please help 🙁

  • 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. Editorial Team
    Editorial Team
    2026-05-20T12:40:25+00:00Added an answer on May 20, 2026 at 12:40 pm

    First thing to do is remove the CATCH, to see the error. We can go from there.

    ALTER TRIGGER [dbo].[trg_ReceiptHistory] 
    ON [dbo].[tblReceipt]
    for UPDATE
    AS 
    --begin try
    INSERT INTO tblHistorySource(RecShipName, RecShipAddress, sourceID)
    select t1.shippingName, t1.shippingAddress, t2.sourceID
    from [DELETED] t1, tblSource t2
    where t2.receiptID = t1.receiptID
    /*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;
    RAISERROR('Error in Source Hisotry Trigger' ,16,1)
    ROLLBACK TRAN
    END CATCH*/
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to create a trigger that will update a GEOMETRY column based
I am trying to write an sql trigger that will update another table whenever
I am trying to create a trigger to update another table with a condition
I am trying to update a table according to this trigger: CREATE TRIGGER alert
I'm trying to create a trigger that will do the following. After insert on
Im trying to make a trigger in mySQL that will update a colum with
All, I am just trying to create a trigger that will pick a whole
I'm trying to write an update trigger that will only update a password when
I am trying to create a Trigger that will run through some IF ELSEIF
I am trying to create a BEFORE INSERT trigger that will check the incoming

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.