:SetVar Function "AUX:ToStringFS.Int"
:r $(DropFunctionScript_AUX)
GO
create function [$(Function)]( @Number int, @AbsValueWidthForZeroPadding int=null )
returns $(dt_AnsiString_AUX)
BEGIN
/*==================================================================================================
# SQLAUX scripting library | Author: Sergei Y.Kitáev
----------------------------------------------------------------------------------------------------
#
# NUMBER CONVERSION TO STRING, WITH FIXED PRECISION (“INT” TYPE):
#
# === Usage: ===
# dbo.[AUX:ToStringFS.Int]( <Number>, <Absolute value width for zero padding> )
# dbo.[AUX:ToStringFS.Int]( <Number>, null )
#
==================================================================================================*/

if @Number is null return null

return dbo.[AUX:ZeroLeftPadByWidthOfAbs](
   CONVERT( $(dt_IntStr_AUX), @Number ),
   ISNULL( @AbsValueWidthForZeroPadding, $(num_IntStrMaxLength_AUX)-1 ) )

/*================================================================================================*/
END
GO
/*
select dbo.[AUX:ToStringFS.Int]( 345178, 10 ) 'Number as string (fixed prec.)'
select dbo.[AUX:ToStringFS.Int]( -8435, 10 ) 'Number as string (fixed prec.)'
*/
