Code set ANSI_NULLS ON set QUOTED_IDENTIFIER ON go
ALTERtrigger[dbo].[addCompanyCount]on[dbo].[CompanyInfo] after insert as declare@CompanyIDint select@CompanyID= CompanyID from inserted update BuildingInfo set companyCount=companyCount+1where BuildID=(select buildbasicid from companyinfo where companyid=@companyid)
Code set ANSI_NULLS ON set QUOTED_IDENTIFIER ON go
ALTERtrigger[dbo].[subCompanyCount]on[dbo].[CompanyInfo] after delete as begin
declare@buildbasicidint select@buildbasicid=buildbasicid from deleted --print @CompanyID update BuildingInfo set companyCount=companyCount-1where BuildID=@buildbasicid end