IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID('[dbo].[mps_prdctg_insert]') AND type = 'TR')
DROP TRIGGER [dbo].[mps_prdctg_insert]
GO
--产品类别插入的触发器
CREATE trigger [dbo].[mps_prdctg_insert] on [dbo].[mps_prdctg] for insert as
begin
    declare
       @maxcard  int,
       @numrows  int,
       @numnull  int,
       @errno    int,
       @errmsg   varchar(255)

    select  @numrows = @@rowcount
    if @numrows = 0
       return

declare @cmpid int 
select top 1 @cmpid = pc_cmpid from  inserted  
set @cmpid = isnull(@cmpid,0)

update mps_tableupdated set tu_updated=0 where  tu_table='mps_prdctg' and tu_cmpid=@cmpid 
insert into mps_sync(sk_type,sk_bizid,sk_objid,sk_operation,sk_tag2) 
select 22 , pc_id , pc_id , 1 , 0 from inserted 

    return

/*  Errors handling  */
error:
    -- raiserror @errno @errmsg
    rollback  transaction
end