I am trying to alter an existing trigger so that it will work for all records that are updated by a command rather that the first record.
(See attached Snippet)
I am getting the following error if i check the syntax or try to execute it:
Msg 102, Level 15, State 1, Procedure Student_Status_Change, Line 31
Incorrect syntax near 'SStatus'.
I have tried to comment out pieces working my way back from I.[SStatus], no matter what i comment out, the same error comes back except it says that the error occurs with the last uncommented "word"
ALTER TRIGGER [dbo].[Student_Status_Change] ON [dbo].[Students]
DECLARE @acct_type AS INT
DECLARE @evt_type AS INT
SET @evt_type = 1
SET @acct_type = 0
DELETE FROM Status_Changes WHERE Status_Changes.[Event_Type] = 1 AND Status_Changes.[Is_Adult] = 0 AND Status_Changes.[Account_ID] IN (SELECT D.Student_ID FROM DELETED D)
INSERT INTO Status_Changes
'SStatus=' + LTRIM(STR(I.[SStatus])),
INNER JOIN DELETED D ON D.[Student_ID] = I.[Student_ID] WHERE D.[SStatus] != I.[SStatus]