MS SQL Server Concepts and Programming Question:
Download Questions PDF

How To Modify Existing Triggers using "ALTER TRIGGER"?

Answer:

If you want to make changes to an existing trigger, you could use the "ALTER TRIGGER" statements to refine the trigger again. The tutorial exercise below shows you how to modify the trigger defined in a previous tutorial:

USE GlobalGuideLineDatabase;
GO

ALTER TRIGGER dml_message ON ggl_users
AFTER INSERT, UPDATE, DELETE
AS
PRINT 'Time: '+CONVERT(VARCHAR(12),GETDATE());
PRINT 'Records are inserted, updated,'
+ ' or deleted in ggl_users';
GO

UPDATE ggl_users SET email='john@ggl' WHERE id = 1;
GO
Time: Jul 1 2007
Records are inserted, updated, or deleted in ggl_users

An extra printing statement is added the trigger.

Download MS SQL Server Interview Questions And Answers PDF

Previous QuestionNext Question
How To List All Triggers in the Database with sys.triggers in MS SQL Server?How To Delete Existing Triggers using "DROP TRIGGER"?