简体   繁体   English

OPENQUERY中的SQL Server datetime2

[英]SQL Server datetime2 in OPENQUERY

We're migrating form SQL Server 2005 to 2014 for a pretty large environment. 我们正在将SQL Server 2005从SQL Server 2005迁移到大型环境。 And we've noticed that OPENQUERY behaves differently when interacting with MySQL database when it comes to datetime. 而且我们已经注意到,在涉及日期时间时,OPENQUERY在与MySQL数据库交互时的行为有所不同。 Previously, it would translate just fine to DATETIME column. 以前,它将可以很好地转换为DATETIME列。 With 2014 (I assume started in 2008 or so), it now converts to DATETIME2 (with maximum precision). 从2014年开始(我假设是从2008年左右开始),现在它转换为DATETIME2(精度最高)。 This causes problems when comparing to or inserting into DATETIME columns. 比较或插入DATETIME列时,这会导致问题。

Is there a way to specify on a server-level (or specify default) for which type those will translate to? 有没有办法在服务器级别上指定(或指定默认值)那些服务器将转换为哪种类型? Rewriting all of the queries will be quite an undertaking, and I'd like to avoid this now, if possible (rather rewrite as we edit or introduce new things). 重写所有查询将是一项艰巨的任务,如果可能的话,我现在想避免这种情况(而不是在我们编辑或引入新事物时进行重写)。

在迁移日期字段时尝试使用VARCHAR数据类型,并且始终很容易根据需要转换/转换各种类型。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM