SQL Server Error Message: Invalid length parameter passed to the substring function
Server: Msg 536, Level 16, State 3, Line 1 Invalid length parameter passed to the substring function.
This error is caused by passing a negative value to the length parameter of the SUBSTRING, LEFT and RIGHT string functions. This usually occurs in conjunction with the CHARINDEX function wherein the character being searched for in a string is not found and 1 is subtracted from the result of the CHARINDEX function.
LEFT(@String, CHARINDEX(' ', @String) - 1)
If the character is not found in a string, a space in this example, the CHARINDEX function will return a value of 0. Subtracting 1 to this will become -1 and using this as the length parameter in the SUBSTRING or LEFT functions will result to this error.
Need Additional Assistance?
Xynomix and we'll assess your issue and help to action a fix.
On submitting this form, Xynomix will store your details and may contact you in relation to your request. For more information on how we process data, please see our privacy notice.
“In the manufacturing sector, we need flexibility and immediate assistance when things go wrong. Xynomix have achieved this brilliantly, and make sure that at least one DBA is available when we call with a problem at any time of the day or night.”
“Xynomix provide us with remote monitoring and administration for Linux, as well as Oracle. The proactive monitoring aspect of our service has proved extremely valuable. Whenever potential issues have been recognised with the system, it has always been identified by the monitoring technology and Xynomix DBAs begin work on a preventative fix immediately.”
“We recently installed a new application which ran on Oracle but was unsure how to correctly license the environment. As a result, we engaged with Xynomix to advise on how best to do so. Xynomix ran an Independent Oracle License Review, which gave us full visibility on our license compliance. They highlighted the restrictions around various license types, whilst also detailing how to avoid any pitfalls moving forward.”
“We have been running Microsoft SQL Server for around two years now and the systems have been supported by Xynomix. Their SQL DBAs are competent and very customer-facing.”