Grumpy Old IT Guy/Intermediate T-SQL - Programming Triggers

  • $5.98

Intermediate T-SQL - Programming Triggers

  • Course
  • 48 Lessons

Triggers automatically execute when events like inserting, deleting, or modifying rows in a table occur, as well as when other events like creating databases, tables, or users logging on occur. You will learn about the different types of triggers, including AFTER triggers, which execute after an SQL operation, and INSTEAD OF triggers, which perform in place of an SQL operation.

Contents

Introduction
DISCLAIMER
Introduction Video
Lesson 01 – Types of Triggers
Lesson 01 - Types of Triggers - Video
Lesson 02 – Trigger Templates
Lesson 02 - Trigger Templates Video
Lesson 03 – Trigger Headers Templates
Lesson 03 - Trigger Header Video
Lesson 04 – A Simple Example
Lesson 04 - Simple Examples Video
Lesson 05 – AFTER Triggers
Lesson 05 - After Triggers - Video
Lesson 06 – INSTEAD OF Triggers
Lesson 06 - Instead of Triggers Video
Lesson 07 – Before INSERT Trigger Simulation
Lesson 07 - Before INSERT Trigger Simulation Video
Lesson 08 – Multi Trigger Sequence
Lesson 08 - Multi Trigger Sequence Video
Lesson 09 – Inventory Example
Lesson 09 - Inventory Example Video
Lesson 10 – Database and Table Triggers
lesson 10 - Database and Table Triggers - Video
Lesson 11 – System Level Triggers
Lesson 11 - System Level Triggers Video
Lesson 12 - Module Summary
Lesson 12 - Module Summary Video

Create Database, Tables and Load Data for Examples

This section contains the SQL code to create the databases used in each lesson, along with objects such as tables, views, stored procedures, triggers, and functions, and, lastly, the BCP script to import data from the text files in the zip file in this section.

The HOBBY_SHOP database is also included but not used in this module. It would be a good idea to create triggers similar to the ones in the lessons, but against the HOBBY_SHP database, which has more data.

Below is a breakdown of the databases used in each lesson:

M4 L1 - TEST DB

M4 L2 - TEST DB

M4 L3 - TEST DB

M4 L4 - TEST DB

M4 L5 - TEST DB

M4 L6 - TEST DB

M4 L7 - TEST DB

M4 L8 - TEST DB

M4 L9 - InventoryM4 DB, all tables created in example script

M4 L10 - TEST DB

M4 L10 - TEST DB

M4 L11 - TEST DB

CREATE DATABASE FINAL-10-15-25.sql
CREATE DATABASE TABLES FINAL-10-15-2025.sql
BCP IN HOBBY_SHOP FINAL-10-15-2025.sql
HOBBY_SHOP_TABLE_BCP_IMPORT-10-31-2025.zip
CREATE INVENTORYM4 DATABASE & TABLES.sql

Module Examples

Here is all the code for the examples discussed in each lesson.

SYSTEM DIAGNOSTIC TOOLS.sql
MODULE 04 - LESSON 01 - TRIGGER TYPES.sql
MODULE 04 - LESSON 02 - TRIGGER CODING TEMPLATES.sql
MODULE 04 - LESSON 03 - TRIGGER HEADER TEMPLATES.sql
MODULE 04 - LESSON 04 - SIMPLE TRIGGER EXAMPLES.sql
MODULE 04 - LESSON 05 - AFTER TRIGGER EXAMPLES.sql
MODULE 04 - LESSON 06 - INSTEAD OF TRIGGER EXAMPLES.sql
MODULE 04 - LESSON 07 - BEFORE TRIGGER SIMULATION.sql
MODULE 04 - LESSON 08 - MULTI TRIGGER SEQUENCE EXAMPLES.sql
MODULE 04 - LESSON 09 - ENHANCED INVENTORY TRIGGER EXAMPLES FINAL.sql
MODULE 04 - LESSON 10 - DATABASE & TABLE EXAMPLES.sql
MODULE 04 - LESSON 11 - SYSTEM LOGON QUERIES.SQL

Homework

In this section, you will find the homework assignments, homework solutions, and a homework template you can use to start you on the homework assignment for the lesson. The homework template is an incomplete solution, and you need to fill in the missing logic. The solutions, of course, are just one of many possible solutions. Try to complete the code on your own and only check out the solutionif you are stuck.

Module 4 - Triggers Homework Assignments.sql
Module 4 - Triggers Homework Assignment Templates.sql
Module 4 - Triggers Homework Solutions V2.sql

SQL Server System Diagnostic Tools for Triggers

A series of queries, stored procedures and dynamic management tools to help you manage your triggers.

SYSTEM DIAGNOSTIC TOOLS.sql