I'm getting frequent errors in code where it says
CustomerSales is not a recognized table hints option. If it is intended as a parameter to a table-valued function, ensure that your database compatibility mode is set to 90.
It's happened with several other tables eg Hires, CustomerNumbers, etc.
I came across this suggestion on google, but I'm not sure if it's the best thing to do? Or what may have caused the error in the first place?
Can anyone please advise what is likely to cause this type of error and the best solution?
ALTER DATABASE database_name SET COMPATIBILITY_LEVEL = { 150 | 140 | 130 | 120 | 110 | 100 | 90 }
An example of the code I get the error with is this:
WITH CustomerAges AS
(
SELECT
P.FirstName, P.LastName,
FLOOR (DATEDIFF(DAY, PD.BirthDate, GETDATE()) / 365.25) AS AGE
FROM
Sales.vPersonDemographics PD
INNER JOIN
Person.Person P ON P.BusinessEntityID = PD.BusinessEntityID
)
SELECT
*,
CASE
WHEN Age IS NULL THEN 'Unknown Age'
WHEN Age BETWEEN 0 and 17 THEN 'Under 18'
WHEN Age BETWEEN 18 and 24 THEN '18 - 24'
WHEN Age BETWEEN 25 and 34 THEN '25 - 34'
WHEN Age BETWEEN 35 and 49 THEN '35 - 49'
WHEN Age BETWEEN 50 and 64 THEN '50 - 64'
ELSE 'Over 65'
END AS AgeRange
FROM
CustomerAges
1条答案
按热度按时间rseugnpd1#
Check the
COMPATIBILITY_LEVEL
and set it to 120; it works for me.