Join Martin Guidry for an in-depth discussion in this video Using database-level triggers, part of SQL Server: Triggers, Stored Procedures, and Functions.
- View Offline
- Exercise Files
The triggers we've seen thus far are all at the table level, meaning they react to…an INSERT, UPDATE, or DELETE statement issued to one table.…SQL Server also supports triggers at the database level.…These trigger fire whenever a statement is issued that would change the…structure of that database.…I have an example staged for you in your exercise files.…This trigger we're saying is on the database on line 2, so that means it applies…to the entire database.…
Line 3 says it is for any attempt to drop a table or any attempt to alter a table.…The body of the trigger is very simple.…It's going to PRINT a message say you do not have permission to drop or alter to…the table and then is going to ROLLBACK.…In other word it's going to undo whatever someone was attempting to do.…So I'll execute this, and now we can find these triggers under the…Programmability menu.…We have a folder called Database Triggers.…If I refresh that, I see the new trigger I just created.…
So let's go ahead and test this trigger.…
- Comparing triggers, functions, and stored procedures
- Installing and configuring SQL Server
- Creating a stored procedure
- Returning data using data sets
- Creating user-defined functions
- Using "after," "instead," and nested triggers
- Modifying existing stored procedures
- Implementing logging on DELETE
- Choosing between T-SQL and CLR
- Executing a stored procedure
- Passing parameters
Skill Level Advanced
1. Getting Started
2. Installing SQL Server
Configuring your environment4m 53s
3. Stored Procedures
4. User-Defined Functions
6. Putting It All Together
7. Using CLR Assemblies
8. Exploring an ASP.NET Web Application
Next steps1m 43s
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.