Skip to main content

Trigger command

Trigger command is used to show notification if something
is altered in the table like the table could be updated or deleted etc
As an example to show how the trigger command works,
I made a table and here is the query--

SET NOCOUNT ON /*helps to turn on to notify us 
                whenever there is update or insert operations done on our table*/

CREATE TABLE Source (Sou_ID int IDENTITY, Sou_Desc varchar(10))
go
CREATE TRIGGER tr_Source_INSERT
ON Source
FOR INSERT
AS
PRINT GETDATE()
go 
 
INSERT Source (Sou_Desc) VALUES ('Test 1')
 
output:::
---------------------
today's date and time

Comments