Possible Duplicate:
How do I get date/time information from a TIMESTAMP column?
How to convert SQL Server’s timestamp column to datetime format
我正在尝试执行一个插入时间戳的简单查询。查询运行没有问题,但这是插入到列中的内容,而不是当前时间:
0x00000000000007D2
这是查询:
INSERT INTO auctions (title, description, finish_date)
VALUES ('Some title', 'Some description', '05/03/2003 11:15:45')
根据我读到的内容Timestamp
已被名为 Rowversion
的东西弃用但我在管理工作室找不到这样的数据类型。
拍卖表:
-
auction_id - bigint
-
title - nvarchar(MAX)
-
description - nvarchar(MAX)
-
start_date - timestamp
-
finish_date - datetime
最佳答案
您不能使用 Timestamp 类型来存储日期。
时间戳基本上是在单个数据库中完成的插入和更新操作的计数器,因此它对于给定数据库来说是本地的并且没有实时值。
为了符合您的插入语句,您应该使用 DateTime 来代替 - 对于您的 start_date
和 finish_date
。
查看此链接:http://msdn.microsoft.com/en-us/library/ms182776(v=sql.90).aspx
关于sql-server - SQL Server INSERT 时间戳插入其他内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14030962/