IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID('[dbo].[order_249_authority_factor_insert]') AND type = 'TR')
DROP TRIGGER [dbo].[order_249_authority_factor_insert]
GO
CREATE  trigger order_249_authority_factor_insert on order_249_authority_factor for insert as
begin 

declare @s1 nvarchar(4000) = '' 
select @s1 = @s1 + case when @s1>'' then ',' else '' end+CONVERT(varchar(10),ordaf_ordid)+':'+CONVERT(varchar(10),ordaf_id) 
from inserted where ordaf_done=0 order by ordaf_ordid 
if (@s1>'') 
begin
insert into mps_task_kernel(tsk_command,tsk_type,tsk_bizid,tsk_ordid,tsk_from,tsk_reason)
values('exec mps_sys_calc_bizpower_authority 1,249,'''+@s1+'''','biz',249,0,'authority_factor','新建业务，计算权限')
end
end