title: SQL Server trigger not allowing to insert data or modify it
body: <p>I have table which was allowing to enter before I created few new columns in that table. The table calls trigger on UPDATE, DELETE and INSERT which insert data in his log History table I created with the same columns in <code>History</code> table.</p>
  
  <p>Now it is not allowing me to insert the data in the table it shows. When I edit in row from the edit option it showing this error..... </p>
  
  <pre><code>No row was Updated.
  The data in row 1 was not committed 
  Error Sources .net SQLClient Data Provider.
  Error Message: Incorrect syntax near the keyword where 
  Correct the error and retry or press esc to cancel 
  </code></pre>
  
  <p>But if I disable the trigger everything works fine.</p>
  
  <p>Trigger</p>
  
  <pre><code>SET ANSI_NULLS ON
  GO
  SET QUOTED_IDENTIFIER ON
  GO
  
  ALTER TRIGGER [magic  ].[magic  ]
  ON magic
  AFTER UPDATE, INSERT, DELETE
  AS 
      DECLARE @operation CHAR(20) 
      SET @operation= 'N' 
  
      IF EXISTS(SELECT * FROM inserted) AND EXISTS(SELECT * FROM deleted) 
      BEGIN
          SET @operation = 'Updated'
  
          INSERT INTO magic.magic_HISTORY
              SELECT *, @operation 
              FROM INSERTED
      END
  
      IF EXISTS(SELECT * FROM inserted) AND NOT EXISTS(SELECT * FROM deleted)
      BEGIN
          SET @operation = 'Inserted'
  
          INSERT INTO magic.magic_HISTORY
              SELECT *, @operation 
              FROM INSERTED
      END
  
      IF NOT EXISTS(SELECT * FROM inserted) AND EXISTS(SELECT * FROM deleted)
      BEGIN
          SET @operation = 'Deleted'
  
          INSERT INTO magic.magic_HISTORY
              SELECT *, @operation 
              FROM deleted
      END
  </code></pre>