--:SetVar Function "AUX:EmptyAsNull"
if exists( select * from [sysobjects] (nolock) where [type] in ('FN','TF') and [name]=N'AUX:EmptyAsNull' )
   drop function [AUX:EmptyAsNull]
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:EmptyAsNull]( @String nvarchar(max) )
returns nvarchar(max)
BEGIN
/*==================================================================================================
# SQLAUX scripting library | Author: Sergei Y.Kitáev
----------------------------------------------------------------------------------------------------
#
# SUBSTITUTION OF EMPTY STRING WITH NULL:
#
# === Usage: ===
# dbo.[AUX:EmptyAsNull]( <String> )
#
==================================================================================================*/

return IIF( @String<>'', @String, null )

/*================================================================================================*/
END
GO
/*
select dbo.[AUX:EmptyAsNull]( N'qwerty' ) 'Empty string as null'
select dbo.[AUX:EmptyAsNull]( '' ) 'Empty string as null'
select dbo.[AUX:EmptyAsNull]( ' ' ) 'Empty string as null'
select dbo.[AUX:EmptyAsNull]( null ) 'Empty string as null'
*/
