About the following trigger:
CREATE TRIGGER [dbo].[TG_TESTE]
ON [MINHABASE].[dbo].[TB_DOCUMENTOS]
AFTER UPDATE
AS
DECLARE @ID INT
DECLARE @DOC INT
DECLARE @QTD FLOAT
SELECT TOP 1 @ID = ID, @DOC = DOCUMENTO, @QTD = QUANTIDADE
FROM dbo.TB_DOCUMENTOS
WHERE OPERACAO = 177
AND STATUS = 1
ORDER BY ID DESC
-- CONDICAO
BEGIN
SET NOCOUNT ON;
UPDATE dbo.TB_DOCUMENTOS
SET PESO = 1000
WHERE ID = @ID
END
In the query, I make the filter and set the variables @ID, @DOC, @QTD
.
When this query DOES NOT return a record, will the trigger run update
within BEGIN
, even if I do not have a condition above?