:SetVar Function "AUX:HasSignificantSpaces"
:r $(DropFunctionScript_AUX)
create function [$(Function)]( @String $(dt_String_AUX) )
returns bit
BEGIN
/*==================================================================================================
# SQLAUX scripting library | Author: Sergei Y.Kitáev
----------------------------------------------------------------------------------------------------
#
# CHECKING, IF STRING CONTAINS SIGNIFICANT (NON-TRAILING) SPACES:
#
# === Usage: ===
# dbo.[AUX:HasSignificantSpaces]( <String> )
#
==================================================================================================*/

if @String is null or DATALENGTH( @String )=0
   return 0

declare @SpaceIdx int
set @SpaceIdx = CHARINDEX(' ',@String,1)
if @SpaceIdx between 1 and LEN(@String)
   return 1

return 0

/*================================================================================================*/
END
GO
/*
select dbo.[AUX:HasSignificantSpaces]( N'qwerty' ) 'Contains significant spaces'
select dbo.[AUX:HasSignificantSpaces]( N'qwerty ' ) 'Contains significant spaces'
select dbo.[AUX:HasSignificantSpaces]( N'qwer ty' ) 'Contains significant spaces'
select dbo.[AUX:HasSignificantSpaces]( N' qwerty' ) 'Contains significant spaces'
select dbo.[AUX:HasSignificantSpaces]( ' ' ) 'Contains significant spaces'
select dbo.[AUX:HasSignificantSpaces]( '' ) 'Contains significant spaces'
select dbo.[AUX:HasSignificantSpaces]( null ) 'Contains significant spaces'
*/
