Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
schauhan13
Starting Member
1 Post |
Posted - 2009-08-27 : 14:46:08
|
| Here is my trigger :-set ANSI_NULLS ONset QUOTED_IDENTIFIER ONgoALTER TRIGGER [insAssemblyParts] ON [dbo].[Schedule_EMPD_SD] FOR INSERTASdeclare @drqj varchar(10)set @drqj =( select drqj from inserted )declare @wr02 varchar(5)set @wr02 = (select wr02 from inserted )declare @sqna varchar(5)set @sqna = (select sqna from inserted)declare @wr01 varchar(5)declare @qnty intset @qnty=(select qnty from inserted)set @wr01= (select wr01 from inserted)declare @litm varchar(35)set @litm = (select litm from Schedule_Empd where sqna=@sqna and drqj=@drqj and wr02=@wr02 )declare @uorg intset @uorg = (select uorg from Schedule_Empd where sqna=@sqna and drqj=@drqj and wr02=@wr02 )declare @sdate datetimeset @sdate = (SELECT DATEADD(dd, CONVERT(int, RIGHT(@drqj, 3)) - 1, CONVERT(datetime,SUBSTRING(@drqj,1,2)+'0101', 212)))declare @qty intif (select wr01 from inserted) ='1000' or (select wr01 from inserted) ='2000' or (select wr01 from inserted) ='2005' beginset @qty=@uorg * @qntyinsert into AssemblyParts( sqna,litm,wr01,ScheduleDate,QtyNeeded) values(@sqna,@litm,@wr01,@sdate,@qty)endif (select wr01 from inserted) ='3302'if (select count(*) from AssemblyParts where sqna=@sqna and wr01=@wr01 and scheduledate=@sdate and litm=@litm) > 0beginset @qty = 2* @uorg * @qntyupdate AssemblyParts set QtyNeeded=@qty where sqna=@sqna and wr01=@wr01 and scheduledate=@sdate and litm=@litm)endelseset @qty=@uorg * @qntyinsert into AssemblyParts(sqna,litm,wr01,ScheduleDate,QtyNeeded) values(@sqna,@litm,@wr01,@sdate,@qty)And it is giving me following error:-Msg 170, Level 15, State 1, Procedure insAssemblyParts, Line 35Line 35: Incorrect syntax near ')'.Can anyone tell me where i am wrong? |
|
|
rohitkumar
Constraint Violating Yak Guru
472 Posts |
Posted - 2009-08-27 : 15:56:18
|
| an extra ")" at the end of your update statement is causing this |
 |
|
|
GilaMonster
Master Smack Fu Yak Hacker
4507 Posts |
|
|
|
|
|
|
|