The order number column in the jobs table of the SQL database has the following structure: "2006925-06/01".
The string value between the "-" and the "/" denotes the sales order line that links to the job order number in the jobs table. I'm trying to use the following statement to extract the values sales order line value and present it as PulledString. When I execute the statement I get an errorL
Invalid length parameter passed to the LEFT or SUBSTRING function.
Not sure what's wrong?
, CASE WHEN [ordernumber] Is Not Null THEN
SUBSTRING([ordernumber],CHARINDEX('-', [ordernumber], CHARINDEX('-', [ordernumber]) + 1) -0,
LEN([ordernumber]) - CHARINDEX('/', [ordernumber], CHARINDEX('/', [ordernumber]) + 1) -
CHARINDEX('-', REVERSE(rtrim([ordernumber])))) ELSE '' END AS PulledString