要在sqlserver 2005中声明时间,我需要数据类型 [英] To declare time in sqlserver 2005 i need datatype
本文介绍了要在sqlserver 2005中声明时间,我需要数据类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我必须将数据类型声明为时间。如何在sql server 2005中创建表时声明它
I have to declare datatype as time. how to declare it in while creating table in sql server 2005
推荐答案
SQL Server 2005支持DATETIME数据类型,它还包括时间。要只存储时间,可以使用CONVERT语句:
SQL Server 2005 does support the DATETIME datatype, which also includes time. To store only the time, you can use the CONVERT statement:
SELECT CONVERT(DATETIME, '11:22:33')
这不是最佳的,因为未使用日期部分,但仍占用存储空间。但是再一次,将数据库降级到以前的版本永远不是最佳的。
It''s not optimal, because the date part is not used, but still takes up storage space. But then again, downgrading a database to a previous version never is optimal.
对于SQL 2005,我认为您只需要使用DateTime数据类型。然后你可以使用转换为
For SQL 2005, I think you need to use DateTime data-type only. Then you can use convert as
Convert(varchar(10),YourDateTime,108)
在SQL 2008中,你有一个名为Time的数据类型你可以使用
Check,
http://msdn.microsoft.com/ en-us / library / bb677243.aspx [ ^ ]
Milind
In SQL 2008, you have a data-type called "Time" you can use that
Check,
http://msdn.microsoft.com/en-us/library/bb677243.aspx[^]
Milind
时间数据类型在SQL SERVER 2005中不可用
它可用于 SQL SERVER 2008
SQL SERVER 2005中的
Datetime 数据类型可用。
快乐编码!
:)
time datatype is not available in SQL SERVER 2005
it is available in SQL SERVER 2008
in SQL SERVER 2005 Datetime datatype is available.
Happy Coding!
:)
这篇关于要在sqlserver 2005中声明时间,我需要数据类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文