I have to split a string, I need take the first 25 characters and then the others, this is my code
select SUBSTRING(field, 1, 25), SUBSTRING(field, 26, (LEN(field)-25)) from table
but I'm getting this for the second substring:
Invalid length parameter passed to the left or substring function
What's wrong in that?
You can use stuff():
stuff()
select left(field, 25), stuff(field, 1, 25, '')
The problem is that substring() doesn't accept a negative length, which your code calculates.
substring()
2.1m questions
2.1m answers
60 comments
57.0k users