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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T16:18:24+00:00 2026-06-16T16:18:24+00:00

For some reason I can’t find the exact answer that I need. I searched

  • 0

For some reason I can’t find the exact answer that I need. I searched for at last 20 minutes in here.

I know it’s simple. VERY simple. But I can’t fire the trigger for some reason..

I have a table with two columns

dbo.HashTags

|__Id_|_name_|
|  1  | Love |

I want to insert the deleted values into another table called dbo.HashTagsArchive on a DELETE query.

Example:

DELETE FROM [dbo].[HashTags] WHERE Id=1

After this example I should have the deleted row in dbo.HashTagsArchive and the row with Id=1 should be deleted in dbo.HashTags

I tried this TRIGGER:

ALTER TRIGGER [dbo].[HashTags_BeforeDelete]
    ON [dbo].[HashTags]
    FOR DELETE
AS
  BEGIN
    INSERT INTO HashTagsArchive
   ( Id,
     HashTagId,
     delete_date)
   SELECT d.Id, m.HashTagId,GETUTCDATE() FROM deleted d 
   JOIN dbo.HashTags m ON m.Id=d.Id
    DELETE FROM dbo.HashTags
    WHERE ID IN(SELECT deleted.Id FROM deleted)
  END
GO

It’s getting Deleted but no Inserted row in the HashTagsArchive

  • 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-16T16:18:25+00:00Added an answer on June 16, 2026 at 4:18 pm

    Your problem is: this trigger fires AFTER the delete has already happened. So there is no more row in HashTags which you could join on!

    You need to use this trigger instead:

    ALTER TRIGGER [dbo].[HashTags_BeforeDelete]
        ON [dbo].[HashTags]
        FOR DELETE
    AS
      BEGIN
        INSERT INTO HashTagsArchive(Id, HashTagId, delete_date)
           SELECT 
               d.Id, d.HashTagId, GETUTCDATE() 
           FROM deleted d 
      END
    GO
    

    The Deleted pseudo table contains the whole row(s) that were deleted – no need to join on anything…

    Also: this trigger fires after the delete has happened – so you don’t need to do anything yourself, inside the trigger – just insert those bits of information into your archive table – that’s all. Everything else is handled by SQL Server for you.

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

Sidebar

Related Questions

I am surprised I can't find this answer but for some reason can't find
For some reason I can only find plugin examples that are directly bound to
I know PHP 5 already supports SQLite but for some reason I can't get
For some reason I can't find any documentation in disabling the resize functionality.
For some reason I can't change HTML after a javascript timeout. Here's the code
For some reason I can't get python to find cairo. When I did ./waf
This question is pretty simple I for some reason can't get the proper result
For some reason I can't get open() to open a file. Here's my code.
There are some breakpoints in my project that for some reason can not be
I'm dealing with a scrupt that for some reason can't read normal $_GET and

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.