SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO
CREATE procedure [dbo].[p_grid_act_accounts]
	@actor_id int,
	@account_number varchar(50) = '%'

as
	set nocount on;

	select	aa.*,
			ac.cur_l1, ac.cur_l2, ac.cur_l3,
			vab.adr_complete_name 
	from act_accounts aa
		inner join vw_act_banks vab on vab.act_actor_id = aa.acc_bank_id
		inner join acc_currencies ac on ac.cur_currency_code = aa.acc_currency_code
	where		aa.acc_actor_id = @actor_id
			and ( @account_number = '%' or aa.acc_account_number = @account_number)
GO
