-- ============================================= -- Author: <Author,,Name> -- Create date: <Create Date, ,> -- Description: <Description, ,> -- ============================================= CREATE FUNCTION [C6MartPeriodico].[getTrimestreDettMov] ( -- Add the parameters for the function here ) RETURNS VARCHAR(8) AS BEGIN -- Declare the return variable here DECLARE @Valore VARCHAR(8) SELECT @Valore = max(DTTRIM) FROM [C6StagingPeriodico].[W6APTR] WHERE DTTRIM not in ('99999999') -- Return the result of the function RETURN @Valore END