I need to do the following in a trigger:
IF NOT EXISTS(SELECT...) --record doesn't exist
IF inserted.CODE = "N" --CODE = "N"
INSERT INTO...
SELECT..
FROM table
ELSE --record doesn't exist & CODE = "S"
INSERT INTO...
SELECT...
FROM another table...
ELSE IF inserted.CODE = "N" --record exists & CODE = "N"
UPDATE table
SET...
FROM table...
UPDATE table
SET...
FROM table...
ELSE --record exists & CODE = "S"
INSERT INTO...
SELECT...
Is there a cleaner way - I think I'm so used to IIf statements in Access that I may not have the TSQL logic correct.
Thanx for any & all help,
Beth L
IF NOT EXISTS(SELECT...) --record doesn't exist
IF inserted.CODE = "N" --CODE = "N"
INSERT INTO...
SELECT..
FROM table
ELSE --record doesn't exist & CODE = "S"
INSERT INTO...
SELECT...
FROM another table...
ELSE IF inserted.CODE = "N" --record exists & CODE = "N"
UPDATE table
SET...
FROM table...
UPDATE table
SET...
FROM table...
ELSE --record exists & CODE = "S"
INSERT INTO...
SELECT...
Is there a cleaner way - I think I'm so used to IIf statements in Access that I may not have the TSQL logic correct.
Thanx for any & all help,
Beth L