When I run this it doesn’t throw an error however it doesn’t insert/delete an entry either. I don’t know why it’s not working.
DECLARE @trAction VARCHAR(5)
SET @trAction = 'addTR'
IF EXISTS (SELECT TransgeneID
FROM tbl_MT
WHERE MouseID = '3' AND TransgeneID = '3')
IF (@trAction = 'rmvTR')
DELETE
FROM tbl_MT
WHERE MouseID = '3' AND TransgeneID = '3'
ELSE
IF (@trAction = 'addTR')
INSERT INTO tbl_MT
VALUES ('3', '3')
First, put
BEGINandENDon theIF's:Second and final, if the first
IFis true, the innerIF (@trAction = 'rmvTR')will fail and nothing will be done.