当我运行它时,它不会引发错误,但它也不会插入/删除条目。我不知道为什么它不起作用。
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')