Trigger & Stored Procedure In SQL Server Part VII

Trigger & Stored Procedure In SQL Server


Trigger :

  • Triggers are nothing but they are logic’s like stored procedures that can be executed automatically before the Insert, Update or Delete, Or after the Insert, Update, or Delete.
There are Two Types of Triggers :

1) Instead of Triggers :
  • The Instead of trigger fires before the operations such as Insert, Update or Delete,  this trigger is going to be fired.
2) After Triggers :
  • The After Triggers fires after the operations such as Insert, Update or Delete,  this trigger is going to be fired.
Note :
  • The Insert, Update and Delete statements are also known as Triggering SQL statements as these statements are responsible for the trigger to fire.
Creating Trigger in SQL Server

1) Select Trigger then Right click on Trigger and select new Trigger in tables : 

Example :

2) Create Trigger :

3) Triggers are Created successfully :


4) Output of Trigger :


Stored Procedure :
  • Stored procedure is nothing but it is block of code which we  can code reusable.
  • The stored procedure increase the performance are pre-compiled and there syntax and plans are already checked.
Creating Stored Procedure in SQL Server

1) Expand Programmability and select Stored Procedures then Right click on Stored Procedures and select new Stored Procedures in tables : 


Example :

2) Create Procedure :


3) Stored Procedures are Created successfully :


4) Execute Stored Procedures :



For more Understanding Watch the below Video :


Comments

Popular posts from this blog

Basic Concept In C Sharp Day 16

VS Code In JavaScript Day 6

ASP.NET MVC Interview Questions Part - II Day 26