Trigger Restrictions
There are a handful of restrictions that apply to triggers. First and foremost, there are a number of commands that are invalid within triggers because triggers run within (at least) implicit transactions, and these commands are not allowed within transactions:
ALTER DATABASE
CREATE DATABASE
DISK INIT
DISK RESIZE
DROP DATABASE
LOAD DATABASE
LOAD LOG
RECONFIGURE
RESTORE DATABASE
RESTORE LOG
UPDATE STATISTICS
Because a number of commands require that they be the first statement in the current batch, running them from within a stored procedure or trigger requires special treatment. Examples of statements that must be the first statement in a batch include CREATE VIEW, CREATE PROCEDURE, and many others. Here's a trigger that creates a ...
Get Guru's Guide to SQL Server™ Stored Procedures, XML, and HTML, The now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.