The SUBSTRING function has the following syntax:
SUBSTRING ( expression, start, length )
Notes:
To get around the NULL expression scenario, use the CASE WHEN ... expression in TSQL.
References:
https://docs.microsoft.com/en-us/sql/t-sql/language-elements/case-transact-sql
https://docs.microsoft.com/en-us/sql/t-sql/functions/substring-transact-sql