Home

Triggers should not PRINT, SELECT, or FETCH

Rule description

  • Triggers should not PRINT, SELECT, or FETCH

 

Non-compliant Code Example

CREATE TRIGGER [DATA].Employee_Count
ON [DATA].EMPLOYEE
AFTER DELETE
AS
BEGIN
	DECLARE @n int
    SELECT @n = COUNT(*) FROM [DATA].EMPLOYEE   --Non compliant code (Trigger is having Select clause)
    PRINT ' There are now ' + CAST(@n as nvarchar(10)) + ' employees.' --Non compliant code (Trigger is having Print clause)
END
Visual Expert 2020
 VETSQLRULE47