Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Control Flow Language

Status
Not open for further replies.

budbeth

Programmer
Oct 29, 2002
31
0
0
US
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
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top