Mar 24, 2014

'' is an invalid event type. Sql server


Suppose we have created tblTarget using following sql script in sql server:

CREATE TABLE tblTarget(
    ID int IDENTITY(1,1) PRIMARY KEY,
    vcData varchar(500) NULL,
)

Now if create trigger by executing following sql statement:

CREATE TRIGGER trgTarger ON tblTarget
FOR DELETED
AS
SELECT 1

We will get error message:

'DELETED' is an invalid event type.

Cause: DELETE is invalid trigger event types. Valid trigger events are:

1. INSERT
2. UPDATE
3. DELETE

Solution:

Correct syntax for creating trigger is:

CREATE TRIGGER trgTarger ON tblTarget
FOR DELETE
AS
SELECT 1

No comments:

Post a Comment