Jasinski Technical Wiki

Navigation

Home Page
Index
All Pages

Quick Search
»
Advanced Search »

Contributor Links

Create a new Page
Administration
File Management
Login/Logout
Your Profile

Other Wiki Sections

Software

PoweredBy

DDL Trigger Sample - SQL Server

RSS
Modified on Tue, Nov 18, 2014, 7:54 AM by Administrator Categorized as 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;

ScrewTurn Wiki version 3.0.1.400. Some of the icons created by FamFamFam. Except where noted, all contents Copyright © 1999-2024, Patrick Jasinski.