Hi
I have a view that as stopped working.
I have copied the SQL into a query and I get the error message
Msg 537, Level 16, State 2, Line 1
Invalid length parameter passed to the LEFT or SUBSTRING function.
The code is below. Any ideas where I should be looking to sort the issue. Thanks
I have a view that as stopped working.
I have copied the SQL into a query and I get the error message
Msg 537, Level 16, State 2, Line 1
Invalid length parameter passed to the LEFT or SUBSTRING function.
The code is below. Any ideas where I should be looking to sort the issue. Thanks
SQL:
SELECT dbo.Machine.Name, dbo.[148-LastPackNumber](dbo.Machine.MachineID) AS LastPackNumber, dbo.[148-vwMaximumPackNumber].MaximumPackNumber,
dbo.[148-vwMaximumPackNumber].MaximumPackNumber - dbo.[148-LastPackNumber](dbo.Machine.MachineID) AS [Numbers Reserved], dbo.[148-vwDailyPacks].[Daily Average],
(dbo.[148-vwMaximumPackNumber].MaximumPackNumber - dbo.[148-LastPackNumber](dbo.Machine.MachineID)) / CONVERT(int, dbo.[148-vwDailyPacks].[Daily Average]) AS [Days Left],
CASE WHEN Machine.MachineID = 10 THEN 1 ELSE CASE WHEN Machine.MachineID = 15 THEN 2 ELSE CASE WHEN Machine.MachineID = 25 THEN 3 ELSE CASE WHEN Machine.MachineID = 20 THEN 4 ELSE 5
END END END END AS Line
FROM dbo.Machine INNER JOIN
dbo.[148-vwDailyPacks] ON dbo.Machine.MachineID = dbo.[148-vwDailyPacks].MachineID INNER JOIN
dbo.[148-MachineLookup] ON dbo.Machine.MachineID = dbo.[148-MachineLookup].MachineID LEFT OUTER JOIN
dbo.[148-vwMaximumPackNumber] ON dbo.Machine.MachineID = dbo.[148-vwMaximumPackNumber].MachineID
ORDER BY Line