我想寫一個觸發器:如果在一個表中存在的記錄,更新另一個表,如果不存在插入到該表 我得到一個錯誤創建這個觸發器:多部分組成的標識符「插入的」無法綁定
CREATE TRIGGER TR_update_laststatus_on_membersservices ON [dbo].[activemembers] AFTER
INSERT AS
BEGIN
IF EXISTS
(
SELECT 1
FROM [membersservices]
WHERE [membersservices].[mobilenumber] = INSERTED.[mobilenumber]
AND [membersservices].[sid] = INSERTED.[sid]
)
BEGIN
UPDATE membersservices
SET membersservices.[last_status] = INSERTED.enable
WHERE membersservices.mobilenumber=INSERTED.mobilenumber and membersservices.[sid]=INSERTED.[sid]
END
ELSE
INSERT INTO membersservices VALUES (INSERTED.[mobilenumber] ,INSERTED.[sid] ,INSERTED.[enable] , INSERTED.[dt]);
end
有什麼錯誤? – Dhwani
多部分標識符「INSERTED.mobilenumber」無法綁定 – mnshahab