If @FN_InputDt is null, then @MonthNo will also be null, so you can just skip checking if @FN_InputDt is null.
You can also skip another case by simply using @MonthNo as an index to select part of the string:
set @Result = substring(
'JANFEBMARAPRMAYJUNJULAUGSEPOCTNOVDEC',
@MonthNo * 3 - 2,
3
)
If @MonthNo is null @Result will also be null.
Guffa source
share