DDL Trigger Sample - SQL Server

This DDL trigger will print the text Command(s) completed successfully. John Doe eats worms. whenever a function, procedure, or view is created or altered in the current database. To change the scope to the entire server, change on database to on all server.

create trigger TestTrigger
on database
for create_function, alter_function, create_procedure, alter_procedure, create_view, alter_view
as begin

print 'Command(s) completed successfully.  John Doe eats worms.'

end

Another Example

CREATE TRIGGER safety 
ON DATABASE 
FOR DROP_TABLE, ALTER_TABLE 
AS 
   PRINT 'You must disable Trigger "safety" to drop or alter tables!' 
   ROLLBACK;