26.7.08

DDL Triggers in SQL Server 2005

DDL Trigger -> Its a new concept introduced in SQL Server 2005.Its used to control and monitor the DDL statements executed in our database.Consider the below example,I have created a DDL trigger for drop statement. Now, if a user tried to drop my tables. It will be automatically throw an error message.


Code Snippet

CREATE TRIGGER DDLTriggertoSaveTable ON DATABASE FOR DROP_TABLE

AS PRINT 'M No way to delete the tables in the Database?'


Now, execute the below statement,

Code Snippet
Drop Table VenkatTestDLLTriggers



You will get a message indicating "Cannot drop the tables in the database.

Happy Learning!!!

Regards,

Venkatesan Prabu .J

No comments:

Post a Comment