I've been trying this all morning and can't find what I'm doing wrong. I have a string, 'XXYY0000' and I need the XX and YY seperatly.
So this works and gets the XX values:
SELECT LEFT(l.LOAN_MATURITY, 2)
FROM LOAN As l
But why is this not working when I need to get the YY values?
SELECT SUBSTRING(l.LOAN_MATURITY, 3, 2)
FROM LOAN As l
I researched and it should give the same output as the MID() function, but it gives me this error.
Msg 8116, Level 16, State 1, Line 1
Argument data type numeric is invalid for argument 1 of substring function.
Why is the data type important for the SUBSTRING function but not the LEFT function?
l.LOAN_MATURITY?