Tuesday , November 13 2018
Home / DataBase / SQL SERVER / step by step Procedure for Creating DDL Triggers (Part-2)

step by step Procedure for Creating DDL Triggers (Part-2)

In Previous Article we seen types of Triggers in SQL Server , now in this article we will know steps for how to create DDL triggers on a table.

Step 1: Create trigger for Understandable message after creation of table.Please follow below screen.

ddl_trigger_step1

Step 2: Create a sample table for testing trigger_for_creating_table trigger.Please follow below screen.

ddl_trigger_step2

Here we have to find a message “Table created successfully”.

Step 3: Create trigger for Understandable message after alter of table.Please follow below screen.

ddl_trigger_step3

Step 4:Alter a sample table for testing trigger_for_alter_table trigger. Here we change size of student_name column in trigger_for_create table.Please follow below screen.

ddl_trigger_step4

Here we have to find a message “Table altered successfully”.

Step 5: Create trigger for Understandable message after deletion of  a table.Please follow below screen.

ddl_trigger_step5

Step 6: Drop a sample table for testing trigger_for_drop_table trigger. Here we drop trigger_for_create table.Please follow below screen.

ddl_trigger_step6

Here we have to find a message “Table dropped successfully”.

Step 7: We can also create trigger for all create,alter and drop statement in one trigger.Please follow below screen.

ddl_all_in_one

Step 8: Create a sample table for testing trigger_for_ddls_table trigger.Please follow below screen.

ddl_all_in_one_step2

Here we have to find a message “Table created successfully” and “You are successfully done either create or alter or drop”.

Note: We can also apply DDL Triggers to alter and drop commands.

Conclusion:

Did you find this post as useful? I hope you liked the article. Please share your valuable suggestions and feedback in the comments.

Print Friendly, PDF & Email

Give us your valuable feedback

comments

About Samba

Check Also

sql server backup script

Backup all databases in SQL Instance with one script

Backup: A copy of SQL Server data that can be used to restore and recover the …