IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID('[dbo].[order_87_g_relation]') AND type = 'P')
DROP PROCEDURE [dbo].[order_87_g_relation]
GO
CREATE  procedure order_87_g_relation(@ordid bigint, @useruid int ) as beginset nocount on select ord_id,ord_bizid,ord_bcid,ord_branch,ord_cmpid,ord_createcuid,ord_createdepart,ord_createdpid,ord_creator,ord_date,ord_key,ord_no,ord_status,ord_title,ord_type,ord_updated,ord_dpid,ord_cuid,ord_depart,ord_empname , @useruid ordp_cuid from order_87 where ord_id=@ordid union allselect ord_id,ord_bizid,ord_bcid,ord_branch,ord_cmpid,ord_createcuid,ord_createdepart,ord_createdpid,ord_creator,ord_date,ord_key,ord_no,ord_status,ord_title,ord_type,ord_updated,ord_dpid,ord_cuid,ord_depart,ord_empname,isnull(ordp_cuid,0) ordp_cuid from order_88 inner join order_87_relation on ordr_rordid=ord_id and ordr_ordid=@ordid and ordr_rcrmid=88 LEFT OUTER JOIN order_88_users on ordp_ordid=ord_id and ordp_type='bizview' and ordp_cuid=@useruid union allselect ord_id,ord_bizid,ord_bcid,ord_branch,ord_cmpid,ord_createcuid,ord_createdepart,ord_createdpid,ord_creator,ord_date,ord_key,ord_no,ord_status,ord_title,ord_type,ord_updated,ord_dpid,ord_cuid,ord_depart,ord_empname,isnull(ordp_cuid,0) ordp_cuid from order_86 inner join order_87_relation on ordr_rordid=ord_id and ordr_ordid=@ordid and ordr_rcrmid=86 LEFT OUTER JOIN order_86_users on ordp_ordid=ord_id and ordp_type='bizview' and ordp_cuid=@useruid union allselect ord_id,ord_bizid,ord_bcid,ord_branch,ord_cmpid,ord_createcuid,ord_createdepart,ord_createdpid,ord_creator,ord_date,ord_key,ord_no,ord_status,ord_title,ord_type,ord_updated,ord_dpid,ord_cuid,ord_depart,ord_empname,isnull(ordp_cuid,0) ordp_cuid from order_78 inner join order_87_relation on ordr_rordid=ord_id and ordr_ordid=@ordid and ordr_rcrmid=78 LEFT OUTER JOIN order_78_users on ordp_ordid=ord_id and ordp_type='bizview' and ordp_cuid=@useruid order by ord_date set nocount off end