Member of the LearnItFirst.com Video Training Network | LearnSqlServer.com | SQL SSIS Training | SQL Programming Tutorials |
LearnSqlServer.com Forums LearnSqlServer.com
Welcome Guest Search | New Posts | Members | Log In | Register

trigger problem Options
ejoeyz_85
Posted: Sunday, February 10, 2008 2:53:54 AM
Rank: Newbie

Joined: 1/14/2008
Posts: 5
Points: 15
Location: Sg Buloh
I've some problem wif my triger statement... after execute this trigger, i got this message "Msg 156, Level 15, State 1, Procedure trig_updateOrganization, Line 28
Incorrect syntax near the keyword 'ELSE'."



What shud i do? Below is my trigger. Somebody help me....

Quote:
set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go

ALTER TRIGGER [trig_updateOrganization]

ON [dbo].[OrganizationDetail]
FOR UPDATE
AS

DECLARE @oldName VARCHAR(100)
DECLARE @newName VARCHAR(100)
DECLARE @oldAdress VARCHAR(100)
DECLARE @newAdress VARCHAR(100)

IF NOT UPDATE(Org_name)

BEGIN
RETURN
END


SELECT @oldName = (SELECT Org_name + ' ' FROM Deleted)
SELECT @newName = (SELECT Org_name + ' ' FROM Inserted)


PRINT 'Organization name changed from "' + @oldName +'" to "' + @newName + '"'
PRINT 'Have a nice day'


ELSE IF NOT UPDATE(Org_address)

BEGIN
RETURN
END


SELECT @oldAdress = (SELECT Org_address + ' ' FROM Deleted)
SELECT @newAdress = (SELECT Org_address + ' ' FROM Inserted)


PRINT 'Organization adress changed from "' + @oldAdress +'" to "' + @newAdress + '"'
PRINT 'Have a nice day'
Frown Frown Frown Frown
Scott Whigham
Posted: Monday, February 11, 2008 2:26:13 PM


Rank: Super Mod

Joined: 3/20/2006
Posts: 345
Points: 748
Location: Dallas, TX
You have an ELSE but no corresponding IF statement... (ELSE IF NOT UPDATE(Org_address))
Users browsing this topic
Guest


Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.
     
Don't Forget!
LearnItFirst.com
Don't Forget!
LearnExchange.com
 
Home | About Us | Support | Contact Us | Privacy | Site Map | Blogs Blogs Refer a Friend and Get a Free Subscription!
© Copyright 2004-2007 LearnItFirst.com LLC. All rights reserved. All trademarks remain the property of their respective owners.
This site is not affiliated in any way with the Microsoft Corporation.