USE [FabApprovalSystem] GO /****** Object: UserDefinedFunction [dbo].[fnPlanConvertPlanNoToDisplayFormat] Script Date: 11/21/2024 11:31:55 AM ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE FUNCTION [dbo].[fnPlanConvertPlanNoToDisplayFormat] ( -- Add the parameters for the function here @PlanNo INT ) RETURNS VARCHAR(10) AS BEGIN -- Declare the return variable here DECLARE @Display VARCHAR(10) -- Add the T-SQL statements to compute the return value here SET @Display = LTRIM( RTRIM( CAST( 'P' + RIGHT( '0000' + ISNULL(CAST(@PlanNo AS VARCHAR(10)), ''), 5 ) AS VARCHAR(50) ) ) ) -- Return the result of the function RETURN @Display END GO