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

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…

Contents