--:SetVar Function "AUX:LocalLanguageName"
if exists( select * from [sysobjects] (nolock) where [type] in ('FN','TF') and [name]=N'AUX:LocalLanguageName' )
   drop function [AUX:LocalLanguageName]
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:LocalLanguageName]()
returns nvarchar(50) -- null
BEGIN
/*==================================================================================================
# SQLAUX scripting library | Author: Sergei Y.Kitáev
----------------------------------------------------------------------------------------------------
#
# LOCAL-LANGUAGE IDENTIFIER FROM CONNECTION PROPERTIES (“Application Name=...#Xxxxx”):
#
# === Usage: ===
# dbo.[AUX:LocalLanguageName]()
#
==================================================================================================*/
declare @AppName sysname
select @AppName = [program_name] from [sysprocesses] (nolock) where [spid] = @@SPID
if @AppName is null
   return null
-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
declare @L int, @P int
set @L = LEN( @AppName )
set @P = @L
while @P > 0
begin
   if SUBSTRING( @AppName, 1, 1 ) = '#' break
   set @P = @P - 1
end
if @P > 0 and @P < @L
   return dbo.[AUX:LocalLanguageNameFromCulture]( SUBSTRING( @AppName, @P+1, @L-@P ) )
return null
/*================================================================================================*/
END
GO
/*
select dbo.[AUX:LocalLanguageName]() 'Current local-language'
*/
