I am trying to write a function the will cut off the first 4 chars in a field. For example if the value of the field is ABC_123_EFG it would return 123_EFG. I have tried to use a combination of the LEFT and LEN functions but haven’t had any success.
Here is what I think it should be …
RIGHT(code, LEN(code) - 4) AS code_concat
But it fails with this error
Msg 536, Level 16, State 2, Line 2
Invalid length parameter passed to the RIGHT function.
What am I doing wrong? Is this the best way to accomplish this?
Use
substring:Or, if it’s a
varchar(max):