﻿
-- =============================================
-- STORED stp_getValidValues
--
-- Author:		S.E.L.
-- Create date:	2015.09.15
-- Description:	gestione selezione dati parametrici tradotti
-- =============================================
CREATE PROCEDURE [dbo].[stp_listValues_getValidValuesTrad] 
(
	@TableName NVARCHAR(50),
	@FieldName NVARCHAR(50),
	@Lingua	 NVARCHAR(3)
)
AS
BEGIN
	SET NOCOUNT ON;

    SELECT  lv.value, ISNULL(v.Traduzione, lv.TableName+lv.FieldName+lv.value) AS label
    FROM	  ListValues lv LEFT OUTER JOIN Vocabolario v 
	   ON  lv.TableName+lv.FieldName+lv.value = v.Lemma 
		  AND v.Lingua	   = @Lingua
    WHERE	  lv.TableName	   = @TableName
	   AND lv.FieldName	   = @FieldName
    ORDER BY	 lv.ordinal
END
