text: IF NOT EXISTS (SELECT * FROM sys.schemas WHERE name = N'S') EXEC('CREATE SCHEMA [S]');
  
  GO
  
  CREATE OR ALTER FUNCTION [S].[Hash]
  (
  	@Key NVARCHAR(MAX)
  )
  RETURNS BINARY(32)
  AS
  BEGIN
  	DECLARE @HashKey BINARY(32)
  
  	IF @Key IS NULL
  		SET @HashKey = HASHBYTES('SHA2_256','');
  	ELSE 
  		SET @HashKey = HASHBYTES('SHA2_256',LTRIM(RTRIM(UPPER(@Key))));
  
  	RETURN @HashKey;
  END;