From ChatGPT:
In SQL Server, SUBSTRING()
does not support negative indexes. So SUBSTRING('ANYSTRING', -1, 1)
doesn't return the last character — it actually returns nothing.
To get the last character of the 'ANYSTRING'
, you need to calculate the position using LEN('ANYSTRING')
.