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

  • Home
  • SEARCH
  • 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 8338457
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T04:35:49+00:00 2026-06-09T04:35:49+00:00

I have been using a TSQL trigger under the assumption that the inserted table

  • 0

I have been using a TSQL trigger under the assumption that the inserted table always contains records for an insert or update and the deleted table always contains records for updates (I am ignoring deletes).

Here is the related MSDN article:

http://msdn.microsoft.com/en-us/library/ms191300.aspx

However, I have encountered situations where both inserted and deleted are empty. Here is a test trigger I have been using.

CREATE TRIGGER [dbo].[InsertUpdateTest] ON [dbo].[Test] 
AFTER INSERT, UPDATE 
AS
    DECLARE @countInserted INT
    DECLARE @countDelete INT

    SET @countInsert = (SELECT COUNT(*) FROM INSERTED)
    SET @countDeleted = (SELECT COUNT(*) FROM DELETED)

    IF (@countInserted = 0 AND @countDelete = 0)
    BEGIN
        print 'Inserted and deleted are both empty'
    END

Under what conditions does this occur?

  • 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-06-09T04:35:50+00:00Added an answer on June 9, 2026 at 4:35 am

    Answering my own question. This occurs when an update statement on the triggered table doesn’t update any rows. The trigger still fires but with empty inserted and deleted tables. For example:

    UPDATE Test Set somefield=0 WHERE id='Values does not exist'
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been using TortoiseSVN for some time and I really like it. I
I have been using Stanford POS Tagger to tag parts of speech in a
I have been using play 1.2.5rc4 for development of one app and I have
I have been using an API to do some work. This is how I
I have been using some Javascript to create a text field once an certain
I have been using the storyboard to make an application and currently there are
I have been using CI just fine using the MySQL driver. I want to
I have been using Matlab 2011b and contourf/contourfm to plot 2D data on a
I have been using the following sort: var query = _cityRepository.GetAll( .OrderBy(item => item.RowKey.Substring(0,
I have been using echo $.sprintf(%01\$.2f,$numvar); for my USD formatting, but I only copied

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.