Mar 20, 2014

Cannot alter trigger '' on '' because this trigger does not belong to this object. Specify the correct trigger name or the correct target object name.


Suppose in my database I have three tables Student, Customer and tblTarget. Now I have created a DML trigger on Student :

CREATE TRIGGER tigStudent
ON Student
FOR INSERT
AS
INSERT tblTarget DEFAULT VALUES

Now I would like to ALTER the tigStudent by using following sql query :

ALTER TRIGGER tigStudent
ON Customer
FOR INSERT
AS
INSERT tblTarget DEFAULT VALUES

We will get error message like:

Cannot alter trigger '' on '' because this trigger does not belong to this object. Specify the correct trigger name or the correct target object name.

Cause: Trigger tigStudent belongs to table Student while we altering the trigger using traget table Student.

Solution:

Replace the Customer table by Student in the above alter trigger statement

ALTER TRIGGER tigStudent
ON Student
FOR INSERT
AS
INSERT tblTarget DEFAULT VALUES

No comments:

Post a Comment