IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID('[dbo].[mps_biztype_query_delete]') AND type = 'TR')
DROP TRIGGER [dbo].[mps_biztype_query_delete]
GO
create trigger [dbo].[mps_biztype_query_delete] on [dbo].[mps_biztype_query] for delete as
begin
    declare
       @maxcard  int,
       @numrows  int,
       @numnull  int,
       @errno    int,
       @errmsg   varchar(255)

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

delete mps_biztype_query_users from deleted where bqlu_bqlid=bql_id 
    return

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