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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T16:59:36+00:00 2026-05-14T16:59:36+00:00

I thought after delete meant that the trigger is not fired until after the

  • 0

I thought “after delete” meant that the trigger is not fired until after the delete has already taken place, but here is my situation…

I made 3, nearly identical SQL CLR after delete triggers in C#, which worked beautifully for about a month. Suddenly, one of the three stopped working while an automated delete tool was run on it.

By stopped working, I mean, records could not be deleted from the table via client software. Disabling the trigger caused deletes to be allowed, but re-enabling it interfered with the ability to delete.

So my question is ‘how can this be the case?’ Is it possible the tool used on it futzed up the memory? It seems like even if the trigger threw an exception, if it is AFTER delete, shouldn’t the records be gone?

All the trigger looks like is this:

ALTER TRIGGER [sysdba].[AccountTrigger] ON [sysdba].[ACCOUNT]  AFTER  DELETE AS 
EXTERNAL NAME [SQL_IO].[SQL_IO.WriteFunctions].[AccountTrigger]
GO

The CLR trigger does one select and one insert into another database. I don’t yet know if there are any errors from SQL Server Mgmt Studio, but will update the question after I find out.

UPDATE:

Well after re-executing the same trigger code above, everything works again, so I may never know what if any error SSMS would give.

Also, there is no call to rollback anywhere in the trigger’s code.

  • 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-14T16:59:36+00:00Added an answer on May 14, 2026 at 4:59 pm

    after means it just fires after the event, it can still be rolled back

    example

    create table test(id int)
    go
    
    
    create trigger trDelete on test after delete
    as
    
    print 'i fired '
    rollback
    

    do an insert

    insert test values (1)
    

    now delete the data

    delete test
    

    Here is the output from the trigger

    i fired

    Msg 3609, Level 16, State 1, Line 1

    The transaction ended in the trigger. The batch has been aborted.

    now check the table, and verify that nothing was deleted

    select * from test
    

    The CLR trigger does one select and
    one insert into another database. I
    don’t yet know if there are any errors
    from SQL Server Mgmt Studio, but will
    update the question after I find out.

    Suddenly, one of the three stopped
    working while an automated delete tool
    was run on it.

    triggers fire per batch/statement not per row, is it possible that your trigger wasn’t coded for multi-row operations and the automated tool deleted more than 1 row in the batch? Take a look at Best Practice: Coding SQL Server triggers for multi-row operations

    Here is an example that will make the trigger fail without doing an explicit rollback

    alter trigger trDelete on test after delete
    as
    
    print 'i fired '
    declare @id int
    select @id = (select id from deleted)
    GO
    

    insert some rows

    insert test values (1)
    insert test values (2)
    insert test values (3)
    

    run this

    delete test
    

    i fired
    Msg 512, Level 16, State 1, Procedure trDelete, Line 6

    Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression.

    The statement has been terminated.

    check the table

    select * from test
    

    nothing was deleted

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

Sidebar

Related Questions

how do I delete an assembly file after application shutdown? This is not as
So i bet i got you curious with that title. =) Here's the scenario
Do you have to pass delete the same pointer that was returned by new,
tl;dr - Could you please expand on the 4 comments in the first code
Hi I have the following problem and I am trying to work out what
I have a table with a bunch of buttons like so: <tr class=hr-table-cell >
i've read a blog about DDD from Matt Petters and according and there it
From Objective-C i'm used to Reference Counting / Retain Counting (same thing). I love
Let me provide a little detail to explain what I'm trying to accomplish before

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.