SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO
CREATE PROCEDURE [dbo].[p_grid_acc_accounts_by_branch_id]
	@branch_id as int,
	@account_number as varchar(50) = '%'
AS

set nocount on


select	acc_account_number, act_internal_reference, adr_name, adr_complete_name, cur_l1, cur_l2, cur_l3 
from	act_actors a 
		inner join adr_addresses on act_address_id = adr_address_id
		inner join act_accounts on acc_actor_id = act_actor_id 
		inner join acc_currencies on cur_currency_code = acc_currency_code 
where	a.act_actor_id = @branch_id
and		(	
		@account_number = '%' 
		or 
		acc_account_number = @account_number
		)
GO
