The topic describes the DF207 T-SQL code analysis rule.
PERFORMANCE
Data-returning SELECT statement is used within the trigger.
Triggers should not return data to the client, as this can lead to unexpected consequences.
It is important to note that using a data-returning SELECT statement within a trigger can have performance implications. Each time the trigger fires, the SELECT statement executes, potentially impacting the overall performance of the database, especially if the SELECT statement retrieves a large amount of data or is executed frequently. Additionally, data-modifying triggers can be affected by the use of data-returning SELECT statements, potentially leading to unexpected behavior or performance issues.
CREATE OR ALTER trigger [labour].[trg_workout]
ON [labour].[workout]
AFTER INSERT, UPDATE
AS
BEGIN
SET NOCOUNT ON
SELECT id FROM dbo.demotable
IF EXISTS(SELECT * FROM inserted WHERE Time < 0) ROLLBACK;
END;
GO
CREATE OR ALTER trigger [labour].[trg_workout]
ON [labour].[workout]
AFTER INSERT, UPDATE
AS
BEGIN
SET NOCOUNT ON
IF EXISTS(SELECT * FROM inserted WHERE Time < 0) ROLLBACK;
END;
GO