SQL Server 2014 类型 DATE 不是定义的系统类型 [英] SQL Server 2014 Type DATE is not a defined system type

查看:55
本文介绍了SQL Server 2014 类型 DATE 不是定义的系统类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在存储过程中使用以下查询

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);

它在 Sql Server 2008 中正常工作,而在 Sql Server 2014 中我面临以下错误:

Its working correctly in Sql Server 2008, Where as in Sql Server 2014 I'm facing the below error:

类型 DATE 不是定义的系统类型.

Type DATE is not a defined system type.

推荐答案

如果兼容级别为 90,则表示您没有使用 SQL Server 2014,因为它不支持此兼容级别(最低支持为 100).

If the compatibility level is 90, it means you are not working with SQL Server 2014, since it does not support this compatibility level (lowest supported is 100).

如果您使用的是 2012(支持兼容级别为 90 的最高版本),则应将兼容级别更改为 110.对于 2008/2008 r2 版本,最高兼容级别为 100.

If you are working with 2012 (which is the highest version supporting compatibility level 90), you should change the compatibility level to 110. For 2008 / 2008 r2 version, the maximum compatibility level is 100.

使用 更改数据库:

ALTER DATABASE database_name   
SET COMPATIBILITY_LEVEL = 110 -- or 100 for 2008 versions.

这篇关于SQL Server 2014 类型 DATE 不是定义的系统类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆