Home > Blockchain >  SQL Insert Trigger how to insert the data to A Students table if the inserted marks are a or A
SQL Insert Trigger how to insert the data to A Students table if the inserted marks are a or A

Time:12-27

CREATE TRIGGER [aplusresulttrig] ON [dbo].[sturesults]
    After INSERT
    AS
    BEGIN 
    SELECT d.stuid,d.subid,d.result FROM inserted d
    if(d.result='a ' or d.result='A ')
        INSERT INTO dbo.aplusresult(stuid,subid)
        values(d.stuid,d.subid)     
    END

CodePudding user response:

here is the right syntax :

CREATE TRIGGER [aplusresulttrig] ON [dbo].[sturesults]
    After INSERT
    AS
    BEGIN
       INSERT INTO dbo.aplusresult(stuid,subid) 
       SELECT d.stuid,d.subid
       FROM inserted d
       WHERE d.result in ('a ','A ')  
    END
  • Related