1

is there anyway to put a condition in a SQL server trigger to say fire when field "XYZ" changes ?

EDIT:

what is the correct SQL syntax to basically insert into a new field

Field XZY has changes from Value A to value B

2 Answers 2

2

the trigger will always fire but you can break it's execution by using UPDATE() and COLUMNS_UPDATED methods inside the trigger

Sign up to request clarification or add additional context in comments.

Comments

2

you can have a conditional section anywhere within your trigger statement using

IF UPDATE (column_name)
BEGIN
    IF (SELECT column_name FROM INSERTED) = 'B'
    BEGIN
        /* do something */
    END
END

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.