Zargo
Programmer
- Mar 21, 2005
- 109
Hi all,
I have written a trigger but i think this isn't a smart one. Can some of you check this and write this smarter?
CREATE TRIGGER [transfer] ON dbo.accounting FOR INSERT
AS
update accounting
set t7 = 0
from accounting a
inner join inserted I on a.docid=I.docid where
i.docid in (select docid from docs where invoicetype in ( '5','3','6','7' ))
update accounting
set t7 =
case
when (t4 is null and t5 is null) then cast(0 as varchar)
when t4 is null then cast(t5 as varchar) else cast(t4 as varchar)
end
where docid in (select docid from inserted) and docid in (select docid from docs where invoicetype not in ('3','6','7'))
update accounting
set t7 = (select suppliername from docs where docid in (select docid from inserted)) where docid in (select docid
from inserted)
Thanks in advance!!!
A big star for the golden solution
I have written a trigger but i think this isn't a smart one. Can some of you check this and write this smarter?
CREATE TRIGGER [transfer] ON dbo.accounting FOR INSERT
AS
update accounting
set t7 = 0
from accounting a
inner join inserted I on a.docid=I.docid where
i.docid in (select docid from docs where invoicetype in ( '5','3','6','7' ))
update accounting
set t7 =
case
when (t4 is null and t5 is null) then cast(0 as varchar)
when t4 is null then cast(t5 as varchar) else cast(t4 as varchar)
end
where docid in (select docid from inserted) and docid in (select docid from docs where invoicetype not in ('3','6','7'))
update accounting
set t7 = (select suppliername from docs where docid in (select docid from inserted)) where docid in (select docid
from inserted)
Thanks in advance!!!
A big star for the golden solution