--:SetVar Function "AUX:PadStart.Ext"
if exists( select * from [sysobjects] (nolock) where [type] in ('FN','TF') and [name]=N'AUX:PadStart.Ext' )
   drop function [AUX:PadStart.Ext]
GO
/* Translated by $SQLTRANS utility (SQL-file technology). Method author: Sergei Y.Kitáev.
** Script translation date-time: 2022-11-27 00:29:27.24 (stamp of SQL-file generation). */
create function [AUX:PadStart.Ext]
(
   @String           nvarchar(max),
   @WidthForPadding  int,
   @PadChar          nchar
)
returns nvarchar(max)
BEGIN
/*==================================================================================================
# SQLAUX scripting library | Author: Sergei Y.Kitáev
----------------------------------------------------------------------------------------------------
#
# STRING COMPLEMENT FROM START, WITH PADDING CHAR OR WITH SPACES (EXT.VERSION):
#
# === Usage: ===
# dbo.[AUX:PadStart.Ext]( <String>, <Width for padding>, null )
# dbo.[AUX:PadStart.Ext]( <String>, <Width for padding>, <Padding character> )
#
==================================================================================================*/

if @String is null or @WidthForPadding is null
   return @String

----------------------------------------------------------------------------------------------------

declare @Length int
set @Length = dbo.[AUX:StrLength]( @String )

if @WidthForPadding <= @Length
   return @String

return
   REPLICATE( ISNULL(@PadChar,' '), @WidthForPadding - @Length ) +
   @String

/*================================================================================================*/
END
GO
/*
select '“'+dbo.[AUX:PadStart.Ext]( N'string', 10, null )+'”' 'Complemented string'
select '“'+dbo.[AUX:PadStart.Ext]( N'string', 10, '_' )+'”' 'Complemented string'
select '“'+dbo.[AUX:PadStart.Ext]( N'string', 5, null )+'”' 'Complemented string'
select '“'+dbo.[AUX:PadStart.Ext]( N'string', 5, '_' )+'”' 'Complemented string'
*/
