SQL Server 2012:正在使用的SQL Server版本不支持数据类型“datetime2” [英] SQL Server 2012 : The version of SQL Server in use does not support datatype 'datetime2'

查看:400
本文介绍了SQL Server 2012:正在使用的SQL Server版本不支持数据类型“datetime2”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在执行在SQL Server 2012中SQL Server 2008 R2中创建的存储过程并通过实体数据模型检索数据时,会出现此错误:

While executing a stored procedure created in SQL Server 2008 R2 in SQL Server 2012 and retrieving the data through an Entity Data Model, this error occurs:


正在使用的SQL Server版本不支持数据类型'datetime2'

The version of SQL Server in use does not support datatype 'datetime2'

存储过程在SQL Server中成功执行管理工作室2012年。但问题是回到实体数据模型时。

The stored procedure is executing successfully in SQL Server Management Studio 2012. But the issue is when coming back to the Entity Data Model.

任何人遇到这种问题?

推荐答案

您正在运行的数据库的兼容级别是什么?

What is the compatibility level of that database you're running against?

使用

SELECT compatibility_level 
FROM sys.databases 
WHERE name = 'YourDatabaseNameHere'

DATETIME2 被引入SQL Server 2008 - 所以如果该级别低于100(SQL Server 2008),那么 DATETIME2 数据类型不可用。

DATETIME2 was introduced in SQL Server 2008 - so if that level is below 100 (which is SQL Server 2008), then the DATETIME2 data type isn't available yet.

如果数据库从SQL Server 2005实例升级,最有可能的是,其兼容性级别仍为90(SQL Server 2005)和因此 DATETIME2 数据类型尚不可用。

If the database was upgraded from a SQL Server 2005 instance, most likely, it's compatibility level is still at 90 (SQL Server 2005) and thus the DATETIME2 datatype isn't available yet.

您可以将数据库兼容性级别升级到更新的值:

You can upgrade your database compatibility level to more recent values using:

ALTER DATABASE YourDatabaseNameHere
SET COMPATIBILITY_LEVEL = 100;

其中 level = 100 是SQL Server 2008 / 2008 R2和 level = 110 是SQL Server 2012

where level = 100 is SQL Server 2008 / 2008 R2, and level = 110 is SQL Server 2012

这篇关于SQL Server 2012:正在使用的SQL Server版本不支持数据类型“datetime2”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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