SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO
CREATE PROCEDURE [dbo].[p_grid_pr_products_variables_all_sit]
	@product_code ais_code_short,
	@variable_id varchar(15) = '%'
AS 
	set nocount on

	declare @id int

	if @variable_id = '%'
		select @id = 0
	else
		select @id = convert(int, @variable_id)


	select	v.prdv_variable_id, v.prdv_variable_code, v.prdv_variable_date_setup, n.nmpv_l1, n.nmpv_l2, n.nmpv_l3
	from	pr_products_variables v
			inner join nm_products_variables n on n.nmpv_variable_code = v.prdv_variable_code
	where	prdv_product_code = @product_code
	AND		(
			@id = 0 or prdv_variable_id = @id
			)


GO
