sql-server - SQL Server INSERT 时间戳插入其他内容

标签 sql-server timestamp

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_datefinish_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/

相关文章:

sql-server - 如何在 SQL Server 中同时使用 PIVOT 和 JOIN?

sql-server - 为什么我的查询这么慢? (SQL Server 2008 全文搜索怪异)

sql-server - SQL Server如何在内部存储十进制类型值?

makefile - make 使用 stat 吗?这些数据是否存储在操作系统中?

sql - 是否可以在 DB2 的时间戳列中显式插入值

ubuntu - Ubuntu 9.10 中的可信时间戳日志文件

MySQL GROUP BY 在迁移到 SQL Server 2012 时不起作用

sql - 使用 MOVE 确定 DB RESTORE 的 SQL 数据路径

Python时间增量错误: skipping a day when trying to get tomorrow

java - 将 java.util.Calendar ISO 8601 格式转换为 java.sql.Timestamp