From the course: Complete Guide to Advanced SQL Server
Unlock the full course today
Join today to access over 24,400 courses taught by industry experts.
What are SQL Server triggers? - SQL Server Tutorial
From the course: Complete Guide to Advanced SQL Server
What are SQL Server triggers?
Let's kick things off with a discussion about what triggers are and why they're useful in a SQL Server database. Triggers are a special kind of stored procedure, but instead of starting them manually or calling them with an application like traditional stored procedures, triggers are executed automatically by the server in response to specific events. With triggers, you can essentially have SQL Server watch for a certain activities and then perform actions that you specify whenever those events happen to occur. To create a trigger, you first need to ask yourself two questions. The first question is when do you want the trigger to fire or activate? The second question is what commands do you want the trigger to execute once it started? To answer the "when" question, we have a couple of different options that can be split into three categories. These are the events that SQL Server will be watching for that will start the actions defined in the trigger. The first category is in response…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
-
-
-
-
Automate SQL Server with triggers1m 48s
-
(Locked)
What are SQL Server triggers?3m 37s
-
(Locked)
Two triggers types: INSTEAD OF and AFTER2m 34s
-
(Locked)
Create a trigger to print a message6m 17s
-
Timestamp a table modification5m 31s
-
(Locked)
Firing INSTEAD OF triggers3m 23s
-
(Locked)
Challenge: Create a trigger58s
-
(Locked)
Solution: Create a trigger7m 10s
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-