日期:2014-05-17 浏览次数:20502 次
--drop table tb
create table tb
(billid int,itemno int,goodsid int,unitqty int)
go
--drop trigger trigger_tb
create trigger dbo.trigger_tb
on tb
for insert
as
update tb
set itemno = (SELECT COUNT(1) FROM tb t
WHERE t.billid =t1.billid
AND t.itemno <= t1.itemno)
from tb t1
inner join inserted i
on t1.billid = i.billid
go
insert into tb
select 45, 6, 2 , 1
union all select 45 ,7 ,8 , 2
union all select 45 ,8 ,4 , 6
union all select 45 ,9 ,5 ,2
union all select 45 ,10 ,6 ,300
union all select 45 ,11 ,7 ,350
union