create procedure dbo.%PROC% @sid varchar(30) = null .ARGLIST_FILTER as declare @action_id numeric, @user_id numeric, @state_id numeric, @type_id numeric, @new_state_id numeric begin select @action_id = %ACTION_ID% .CHECK_USER .CHECK_VIEW .ARGCONVERT_FILTER --set forceplan on --.VIEW_LIST -- kashuba_av 17.11.05 (в связи со старым ядром) --set forceplan off declare @id numeric select @id=convert(numeric,@sid) select sid = convert(varchar, t_items.id), state_sid = convert(varchar, t_items.state_id), type_sid = convert(varchar, t_items.type_id), t_items.item_name , t_items.item_remark , state_name=(select t_states.state_name from t_states where t_states.id=t_items.state_id), type_name=(select t_types.type_name from t_types where t_types.id=t_items.type_id), td_depo_docs.out_date as out_date_d, td_depo_docs.in_date as in_date_d, td_depo_docs.who_get, td_depo_docs.who_put, td_depo_docs.out_no, td_depo_docs.in_no, convert(varchar,td_depo_docs.correspondent_id) as correspondent_id_s, convert(varchar,td_depo_docs.payer_id) as payer_id_s, convert(decimal(18,4),td_depo_docs.pay_sum) as pay_sum, convert(varchar,td_depo_docs.initiator_id) as initiator_id_s, convert(varchar,td_depo_docs.document_form_id) as document_form_id_s, td_depo_docs.depo_doc_type, convert(varchar,td_depo_docs.folder_id) as folder_id_s, convert(varchar,td_depo_docs.sum_cur_id) as sum_cur_id_s, td_depo_docs.doc_comment, td_depo_docs.arch_date as arch_date_d, td_depo_docs.arch_no, -- convert(varchar,td_depo_docs.owner_id) as owner_id_s, r1861581670_10000000000030547.partner_short_name as payer_name, r1813581499_10000000000030552.item_name as folder_name, r1714105147_10000000000030553.cur_code as cur_code --.VIEW_CALC from #state_list, t_items , td_depo_docs , t_partners r1861581670_10000000000030547 , t_items r1813581499_10000000000030552 , t_currencies r1714105147_10000000000030553 where td_depo_docs.payer_id *= r1861581670_10000000000030547.id and td_depo_docs.folder_id *= r1813581499_10000000000030552.id and td_depo_docs.sum_cur_id *= r1714105147_10000000000030553.id and (td_depo_docs.folder_id is null or exists(select 1 from #folders_list where folder_id=td_depo_docs.folder_id)) and (td_depo_docs.out_date between @out_date_bb and @out_date_ee or @out_date_nn is null ) and (td_depo_docs.in_date between @in_date_bb and @in_date_ee or @in_date_nn is null ) and isnull(rtrim(ltrim(upper(td_depo_docs.out_no))),'') LIKE isnull('%'+rtrim(ltrim(upper(@out_no_nn)))+'%','%') and isnull(rtrim(ltrim(upper(td_depo_docs.in_no))),'') LIKE isnull('%'+rtrim(ltrim(upper(@in_no_nn)))+'%','%') and (td_depo_docs.correspondent_id between @correspondent_id_bb and @correspondent_id_ee or @correspondent_id_nn is null ) and (td_depo_docs.payer_id between @payer_id_bb and @payer_id_ee or @payer_id_nn is null ) and (td_depo_docs.pay_sum between @pay_sum_bb and @pay_sum_ee or @pay_sum_nn is null ) and (td_depo_docs.initiator_id between @initiator_id_bb and @initiator_id_ee or @initiator_id_nn is null ) and (td_depo_docs.depo_doc_type between @depo_doc_type_bb and @depo_doc_type_ee or @depo_doc_type_nn is null ) and (td_depo_docs.folder_id between @folder_id_bb and @folder_id_ee or @folder_id_nn is null ) and (td_depo_docs.sum_cur_id between @sum_cur_id_bb and @sum_cur_id_ee or @sum_cur_id_nn is null ) and (td_depo_docs.arch_date between @arch_date_bb and @arch_date_ee or @arch_date_nn is null ) and isnull(rtrim(ltrim(upper(td_depo_docs.arch_no))),'') LIKE isnull('%'+rtrim(ltrim(upper(@arch_no_nn)))+'%','%') and (td_depo_docs.owner_id between @owner_id_bb and @owner_id_ee or @owner_id_nn is null ) and (isnull(upper(ltrim(rtrim(t_items.item_remark))),'') LIKE isnull('%'+upper(ltrim(rtrim(@item_remark))) + '%','%')) and #state_list.state_id = t_items.state_id and t_items.id = td_depo_docs.id end