SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO
CREATE PROCEDURE [dbo].[p_grid_act_branches_by_product]
	@product_code as ais_code_short,
	@branch_id as varchar(15) = '%'
AS

set nocount on

declare @id int 

if @branch_id = '%'
	set @id = 0
else
	set @id = convert(int, @branch_id)

select	b.*
from	vw_act_branches b
		inner join pr_products_branches pb on pb.prdb_branch_id = b.act_actor_id
where	pb.prdb_product_code = @product_code
and		(@id = 0 or act_actor_id = @id)
GO
