I am using the below query in the stored procedure
SELECT @ICOUNT = COUNT(*)
FROM MESSAGES
WHERE CAST(CREATEDDATE AS DATE) >= CAST(@STARTDATE AS DATE)
AND CAST(CREATEDDATE AS DATE) <= CAST(@ENDDATE AS DATE);
Its working correctly in Sql Server 2008, Where as in Sql Server 2014 I'm facing the below error:
Type DATE is not a defined system type.
SELECT compatibility_level FROM sys.databases where [name] = <YourDbName>
(replace<YourDbName>
with the actual name of the database. What's the result? Are you sure you are working with 2014 version and not 2012? – TremannSELECT @@VERSION
? – Assignation