SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO
CREATE PROCEDURE [dbo].[p_grid_pr_families_formulas_variables]
    @family_code ais_code_short,
    @formula_code ais_code_short,
    @variable_code ais_code_short = '%',
    @variable_type ais_code_short = '%'
AS 

select	*
from	pr_families_formulas_variables
	inner join nm_products_variables on pffv_variable_code  = nmpv_variable_code
	inner join nm_products_variables_types on nmpv_type_code = nmpvt_type_code
where	pffv_family_code = @family_code
		and pffv_formula_code= @formula_code
		and ( @variable_code = '%' or pffv_variable_code = @variable_code )
		and ( @variable_type = '%' or nmpvt_type_code = @variable_type )

GO
