From the course: SQL Server Database Triggers
Unlock the full course today
Join today to access over 23,400 courses taught by industry experts.
Create a trigger to print a message - SQL Server Tutorial
From the course: SQL Server Database Triggers
Create a trigger to print a message
- [Instructor] Using an after trigger, we can return a custom message to the end user when new data is added into a table. To set this up, I'm going to make sure that I'm using the Kinetico TRG database, and we'll create a new table called DBO.products. This table will have two different columns, one called product ID and the other one called product name. And then, so that we can see what the default message window looks like before we add in a trigger, I'm going to add in a single product for the nine volt battery into the table. Let's execute all of these commands to create the table, and we'll see that default message here. It simply says one row is affected. Now let's customize this message by adding in a trigger. I'm going to click here at the end of line number 13 and come down to line 15, and then scroll my window down just a little bit, so I have more room to type. We start creating the trigger with the create…
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
-
-
-
(Locked)
What are SQL Server triggers?3m 37s
-
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
-
(Locked)
-
-
-
-
-