-- ============================================= -- Author: -- Create date: -- Description: -- ============================================= CREATE FUNCTION [C6MartPeriodico].[getTrimestreDettMov_20170413_bonifica] ( -- 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 [C6StampeCentralizzate].[C6StagingPeriodico].[W6APTR] WHERE DTTRIM not in ('99999999') -- Return the result of the function RETURN @Valore END