

set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go
ALTER trigger [dbo].[addCompanyCount] on [dbo].[CompanyInfo]
after insert
as
declare @CompanyID int
select @CompanyID= CompanyID from inserted
update BuildingInfo set companyCount=companyCount+1 where BuildID=(select buildbasicid from companyinfo where companyid=@companyid)


set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go
ALTER trigger [dbo].[subCompanyCount] on [dbo].[CompanyInfo]
after delete
as
begin
declare @buildbasicid int
select @buildbasicid=buildbasicid from deleted
--print @CompanyID
update BuildingInfo set companyCount=companyCount-1 where BuildID=@buildbasicid
end