Bulk Update Trigger Syntax Error

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]
FOR UPDATE
AS 
BEGIN
 
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
(
	Event_Type, 
	Event_Data, 
	Event_Time, 
	Account_ID, 
	Is_Adult
) 
 
SELECT 
	@evt_type, 
	'SStatus=' + LTRIM(STR(I.[SStatus])), 
	GETDATE(), 
	I.[Student_ID],
	@acct_type
FROM
	INSERTED I
INNER JOIN DELETED D ON D.[Student_ID] = I.[Student_ID] WHERE D.[SStatus] != I.[SStatus]
GO

Open in new window

lbstechAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

jamesguCommented:
what about change

INNER JOIN DELETED D ON D.[Student_ID] = I.[Student_ID] WHERE D.[SStatus] != I.[SStatus]

to

INNER JOIN DELETED D ON D.[Student_ID] = I.[Student_ID] and D.[SStatus] != I.[SStatus]
0
lbstechAuthor Commented:
I have tried that also, the same error comes back each time:
Msg 102, Level 15, State 1, Procedure SIF_Student_Elig_Change, Line 31
Incorrect syntax near 'SStatus'.
0
BrandonGalderisiCommented:
You're missing an END
ALTER TRIGGER [dbo].[Student_Status_Change] ON [dbo].[Students]
FOR UPDATE
AS 
BEGIN
 
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
(
        Event_Type, 
        Event_Data, 
        Event_Time, 
        Account_ID, 
        Is_Adult
) 
 
SELECT 
        @evt_type, 
        'SStatus=' + LTRIM(STR(I.[SStatus])), 
        GETDATE(), 
        I.[Student_ID],
        @acct_type
FROM
        INSERTED I
INNER JOIN DELETED D ON D.[Student_ID] = I.[Student_ID] WHERE D.[SStatus] != I.[SStatus]
END
GO

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
lbstechAuthor Commented:
Thank you so much, My head hurts from hitting it on my desk, I have been staring at this for an hour, I can't believe I missed that.  So much for following examples....
0
BrandonGalderisiCommented:
I think that is probably one of the most USELESS errors SQL server displays.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server

From novice to tech pro — start learning today.