title: How to prevent the trigger from sending an error if the table does not exist?
body: <p>I wrote trigger after deleting a row (user) to drop the table that has the name composed from ID of this row (but not every ID has a table), I don't like to throw exception in code if the table does not exist!</p>
  <pre class="lang-sql prettyprint-override"><code>CREATE TRIGGER AfterDeleteUser
              ON usersProject
              FOR DELETE
              AS DECLARE @IDres VARCHAR(50),
              @tablename VARCHAR(50)
  
  
              SELECT @IDres = ins.IDressource FROM DELETED ins;
              set @tablename = concat('MSG_', @IDres);
              
              SET NOCOUNT ON;
              DECLARE @Sql NVARCHAR(MAX);
  
              SET @Sql = N'DROP TABLE '+QUOTENAME(@tablename)
          
                  EXECUTE sp_executesql @Sql;
              go
  </code></pre>
  <p>I get this error when the table does not exist!</p>
  <blockquote>
  <p>Msg 3701, Niveau 11, État 5, Ligne 7</p>
  <p>Cannot drop the table 'MSG_', because it does not exist or you do not have permission.</p>
  </blockquote>