IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID('[dbo].[userfunc_736_load_sql]') AND type = 'P')
DROP PROCEDURE [dbo].[userfunc_736_load_sql]
GO
CREATE PROCEDURE userfunc_736_load_sql(@cmpid int,   @branchid int,  @userdpid int,  @useruid int,   @userotid int,  @usersecurity int,@ctgid int,@ctgid2 int,@objid bigint,@ordid1 bigint)
as

BEGIN
          insert into order_258
        (ord_khid,ord_khxm,ord_khdh,ord_jzxm,ord_jzdh,ord_khdz,ord_zxmd,ord_cppp,ord_cpxh,ord_gmrq,ord_creator,ord_date,ord_fordid,ord_fbizid,
        ord_zxpt,ord_imh,ord_sqsh,ord_yjddsj,ord_ccxlh,ord_xh1,ord_wtbt,ord_zxgl,ord_clxq)
    select
        a.ord_khid,a.ord_khxm,a.ord_khdh,a.ord_jzxm,a.ord_jzdh,a.ord_khdz,a.ord_zxmd,a.ord_cppp,a.ord_cpxh,a.ord_gmrq,a.ord_creator,getdate(),@ordid1,261,
        b.ord2_zxpt,b.ord2_imh,b.ord2_sqsh,b.ord2_yysj,b.ord2_ccxlh,b.ord2_xh1,b.ord2_ywlx,b.ord2_zj,b.ord2_clxq
        from order_261 a, order_261_2 b where charindex('临', a.ord_no) = 0
        and b.ord2_id = (select max(ord2_id) from order_261 a, order_261_2 b where b.ord2_ordid = @ordid1)
        and b.ord2_ordid = @ordid1
        and a.ord_id = @ordid1
    
    select temp1 = ord_fordid from order_258 where ord_fordid = @ordid1 and ord_fbizid = 261
    exec order_258_newbiz 258,'biz',261,0,0,0,2,0
END