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.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 error trigger

Author  Topic 

kwacz23
Starting Member

44 Posts

Posted - 2012-05-17 : 13:53:21
hi, this trigger give me a error

Msg 102, Level 15, State 1, Procedure ProduktyStan, Line 13
Incorrect syntax near ')'.

could you help me

create trigger ProduktyStan
on produkty
for update
as
if exists (select 'True' from inserted i
join deleted d
on i.produkt_id=d.produkt_id
where (d.[ilosc w magazynie]-i.[ilosc w magazynie])>
0
and d.[ilosc w magazynie]-i.[ilosc w magazynie]>0
)
begin
Raiserror ('Ilosc w magazynie nie moze byc ponizej stanu minimalnego');
Rollback transaction
end

vijays3
Constraint Violating Yak Guru

354 Posts

Posted - 2012-05-17 : 14:53:04
This wont give you compilation error and this will be created .
But at run time this will failed . Try thsi



create trigger ProduktyStan
on produkty
for update
as
if exists (select 'True' from inserted i
join deleted d
on i.produkt_id=d.produkt_id
where (d.[ilosc w magazynie]-i.[ilosc w magazynie])>
0
and d.[ilosc w magazynie]-i.[ilosc w magazynie]>0
)
begin
--Raiserror ('Ilosc w magazynie nie moze byc ponizej stanu minimalnego');
Rollback transaction
end

Vijay is here to learn something from you guys.
Go to Top of Page
   

- Advertisement -