title: SQL Server DDL trigger on drop table
body: <p>I have a database with few tables: tab1, tab2, tab3. How can I create a DDL trigger on drop table <strong>only for tab2</strong> (not for tab1 and tab3). When <code>drop tab2</code> is called I need to update values in this table but not to delete tab2. How can I do this? I found this but don't understand how it works:</p>
  
  <pre><code>create trigger trDatabse_OnDropTable
  on database
  for drop_table
  as
  begin
   set nocount on;
   select
    'Table dropped: ' +
    quotename(eventdata().value('(/EVENT_INSTANCE/SchemaName)[1]', 'sysname')) + N'.' +
    quotename(eventdata().value('(/EVENT_INSTANCE/ObjectName)[1]', 'sysname'));
  end;
  </code></pre>
  
  <p>Thanks!</p>