title: INSERT deleted values into a table before DELETE with a DELETE TRIGGER
body: <p>For some reason I can't find the exact answer that I need. I searched for at last 20 minutes in here.</p>
  
  <p>I know it's simple. VERY simple. But I can't fire the trigger for some reason..</p>
  
  <p>I have a table with two columns</p>
  
  <p><strong>dbo.HashTags</strong></p>
  
  <pre><code>|__Id_|_name_|
  |  1  | Love |
  </code></pre>
  
  <p>I want to insert the deleted values into another table called <code>dbo.HashTagsArchive</code> on a <code>DELETE</code> query.</p>
  
  <p>Example: </p>
  
  <pre><code>DELETE FROM [dbo].[HashTags] WHERE Id=1
  </code></pre>
  
  <p>After this example I should have the deleted row in <code>dbo.HashTagsArchive</code> and the row with <code>Id=1</code> should be deleted in <code>dbo.HashTags</code></p>
  
  <p>I tried this TRIGGER:</p>
  
  <pre><code>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
  </code></pre>
  
  <p>It's getting <code>Deleted</code> but no <code>Inserted</code> row in the <code>HashTagsArchive</code></p>