SQL Server 2005中的日期格式 [英] Date format in SQL Server 2005

查看:93
本文介绍了SQL Server 2005中的日期格式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我疯了,我在第一个和第二个2005年在两个sqlserver 2008R2上传输一些数据库。

在意大利转移使用格式'yyyy-mm-dd hh:mm:ss:nnn'

DTS对日期时间规范的字段进行查询转换:

Hi,
Im going crazy, I'm transferring some data bases on two sqlserver 2008R2 the first and the second 2005.
Being in Italy for transfer using the format 'yyyy-mm-dd hh: mm: ss: nnn'
The DTS have in query transform for fields that are datetime specification:

cast ('<value>' as datetime)

对于那些smalldatetime使用

and for those smalldatetime use

cast ('<value>' as smalldatetime)

,在这两种情况下,'< value> '采用上面指出的格式。

在SQLServer 2008R2上一切正常,而在SQLServer 2005上,我总是报告日期值超出允许范围。

我有验证两个服务器使用相同的SQL COLLATE并且基本语言是相同的(意大利语)并且区域设置是正确的。

我无法理解,我已尝试过属性,如果有的话任何特定的规格,但没有找到任何东西。

有人可以给我正确的方向来解决这个问题。

谢谢



, where in both cases the '<value> 'is in the format indicated above.
On SQLServer 2008R2 everything is OK, while on SQLServer 2005 I always reports that the date value is outside the allowed range.
I have verified that both servers use the same SQL COLLATE and that the base language is the same (italian) and that the regional settings are correct.
I can not understand, I have tried in the properties if there is any particular specification, but have not found anything.
Someone can give me the right direction to solve this problem.
thanks


推荐答案

您需要使用设置日期格式 [ ^ ] comand;)临时更改sql server使用的格式。

例如:

You need to use SET DATEFORMAT[^] comand ;) to temporary change format used by sql server.
For example:
SET DATEFORMAT dmy;
--or
--SET DATEFORMAT ymd;
SELECT CAST(<FieldName> AS DATETIME) AS ProperDateTime



如果你更改它,你将能够导入/导出数据;)



这里,在CP板上,你找到吨类似于你的问题的答案 [ ^ ]。




它的工作原理很好。

我从未使用过这个指令

谢谢
Hi,
it's works fine.
I've never used this instruction
Thanks


这篇关于SQL Server 2005中的日期格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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