IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID('[dbo].[LoadMdTask]') AND type = 'P')
DROP PROCEDURE [dbo].[LoadMdTask]
GO
CREATE proc [dbo].[LoadMdTask](
@str nvarchar(20),
@ordid int
)as
begin
delete from  order_140_102 where ord2_ordid = @ordid
delete from  order_141_102 where ord2_ordid = @ordid

if @str = '加盟-直营' 
begin
insert into order_140_102 (ord2_ordid,ord2_bm,ord2_rwsx,ord2_fzr,ord2_fzcuid,ord2_tag)
select @ordid, ord2_sjx1,ord2_sjx2,ord2_sjx3,ord2_fzcuid,102 from order_233_2 
where ord2_sjx4 = '加盟-直营'
end
else
if @str = '直营-加盟' 
begin
insert into order_140_102 (ord2_ordid,ord2_bm,ord2_rwsx,ord2_fzr,ord2_fzcuid,ord2_tag)
select @ordid,ord2_sjx1,ord2_sjx2,ord2_sjx3,ord2_fzcuid,102 from order_233_2 
where ord2_sjx4 = '直营-加盟'
end
else
/*
if @str = '加盟-加盟'
begin
insert into order_140_102 (ord2_ordid,ord2_bm,ord2_rwsx,ord2_fzr,ord2_fzcuid,ord2_tag)
select @ordid,ord2_sjx1,ord2_sjx2,ord2_sjx3,ord2_fzcuid,102 from order_233_2  
where ord2_sjx4 = '加盟-加盟'
end
else
*/
if @str = '加盟' 
begin
insert into order_141_102 (ord2_ordid,ord2_bm,ord2_rwsx,ord2_fzr,ord2_fzcuid,ord2_tag)
select @ordid,ord2_sjx1,ord2_sjx2,ord2_sjx3,ord2_fzcuid,102 from order_233_2 
where ord2_sjx4 = '关店-加盟'
end
else
if @str = '直营' 
begin
insert into order_141_102 (ord2_ordid,ord2_bm,ord2_rwsx,ord2_fzr,ord2_fzcuid,ord2_tag)
select @ordid,ord2_sjx1,ord2_sjx2,ord2_sjx3,ord2_fzcuid,102 from order_233_2 
where ord2_sjx4 = '关店-直营'
end
end