Hi
Just upgraded to 2016 from 2008 and I am getting this error when running the attached code. I cant find what it is relating to, could someone assist please. Code runs fine in 2008 so presuming something is needed in 2016, Thanks
Msg 242, Level 16, State 3, Line 1
The conversion of a varchar data type to a datetime data type resulted in an out-of-range value.
Just upgraded to 2016 from 2008 and I am getting this error when running the attached code. I cant find what it is relating to, could someone assist please. Code runs fine in 2008 so presuming something is needed in 2016, Thanks
Msg 242, Level 16, State 3, Line 1
The conversion of a varchar data type to a datetime data type resulted in an out-of-range value.
SQL:
SELECT dbo.Product.ProductCode, dbo.Product.Description, dbo.ProductStockOption.StockLevelMin, dbo.ProductStockOption.StockLevelMax, SUM(dbo.ProductAnalysis.QuantityUsed) AS QTYUsed,
dbo.Stock.StockAvailable, dbo.Product.udfTopTier, dbo.[148-vwOnWorksOrder].m3 AS [m3 on WO], dbo.[148-vwOnWOSchedule].ScheduleNumber,
dbo.[148-vwAverageDailyUsageMDF_3Month Version].WorkingDaysL3
FROM dbo.ProductAnalysis INNER JOIN
dbo.Product ON dbo.ProductAnalysis.ProductID = dbo.Product.ProductID INNER JOIN
dbo.ProductStockOption ON dbo.Product.ProductID = dbo.ProductStockOption.ProductID INNER JOIN
dbo.Stock ON dbo.ProductStockOption.ProductID = dbo.Stock.ProductID AND dbo.ProductStockOption.BranchID = dbo.Stock.BranchID INNER JOIN
dbo.[148-vwOnWorksOrder] ON dbo.ProductAnalysis.ProductID = dbo.[148-vwOnWorksOrder].ProductID INNER JOIN
dbo.[148-vwAverageDailyUsageMDF_3Month Version] ON dbo.ProductAnalysis.ProductID = dbo.[148-vwAverageDailyUsageMDF_3Month Version].ProductID LEFT OUTER JOIN
dbo.[148-vwOnWOSchedule] ON dbo.Product.ProductID = dbo.[148-vwOnWOSchedule].ProductID
WHERE (dbo.ProductAnalysis.BranchID IN (1, 9)) AND (dbo.ProductAnalysis.CalendarYear = DATEPART(year, DATEADD(month, - 1, GETDATE()))) AND (dbo.ProductAnalysis.CalendarMonth = DATEPART(month,
DATEADD(month, - 1, GETDATE()))) OR
(dbo.ProductAnalysis.CalendarYear = DATEPART(year, DATEADD(month, - 2, GETDATE()))) AND (dbo.ProductAnalysis.CalendarMonth = DATEPART(month, DATEADD(month, - 2, GETDATE()))) OR
(dbo.ProductAnalysis.CalendarYear = DATEPART(year, DATEADD(month, - 3, GETDATE()))) AND (dbo.ProductAnalysis.CalendarMonth = DATEPART(month, DATEADD(month, - 3, GETDATE())))
GROUP BY dbo.Product.ProductCode, dbo.Product.Description, dbo.ProductStockOption.StockLevelMin, dbo.ProductStockOption.StockLevelMax, dbo.Stock.StockAvailable, dbo.Product.udfTopTier,
dbo.[148-vwOnWorksOrder].m3, dbo.[148-vwOnWOSchedule].ScheduleNumber, dbo.[148-vwAverageDailyUsageMDF_3Month Version].WorkingDaysL3
HAVING (dbo.ProductStockOption.StockLevelMin > 0) AND (dbo.ProductStockOption.StockLevelMax > 0)