在 SQL Server 中插入时间戳值 [英] Inserting timestamp value in SQL Server

查看:215
本文介绍了在 SQL Server 中插入时间戳值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 PHP 将数据从我的 MYSQL 表复制到 SQL Server.

I am trying to copy data from my MYSQL table to SQL Server using PHP.

我有一个需要复制的时间戳值.当我试图复制字段时,它给出了无法插入时间戳值的错误.有没有办法插入时间戳值?

I have a TimeStamp value that needs to be copied. While I am trying to copy the fields, it gave an error that timestamp value cannot be inserted. Is there any way to insert the timestamp value?

这是不可能的,然后将列声明为 nvarchar 将插入时间戳,但我能否在日期范围内搜索数据?

Is it is not possible, then declaring the column as nvarchar will insert the timestamp, but will I be able to search the data in a date range?

有人可以澄清我的疑问吗?

Can anyone please clarify my doubt?

谢谢.

推荐答案

SQL Server 的 TIMESTAMP 日期类型与日期或时间无关 - 它只是一个二进制计数器,它保证总是随着时间的推移而增加,当一行已更新.它用于并发检查.

SQL Server's TIMESTAMP date type has nothing to do with a date or a time - it's just a binary counter which is guaranteed to always increment over time, when a row is updated. It's used for concurrency checks.

这个名字很不幸——但它实际上只是一个系统指标.您不能在这样的列中设置或插入值 - 这些是由 SQL Server 本身严格处理的.

The name is unfortunate - but it's really just a system-indicator. You cannot set or insert a value into such a column - those are handled strictly by SQL Server itself.

对于日期/时间,在 2005 年之前的 SQL Server 中使用 DATETIMESMALLDATETIME,SQL Server 2008 还提供其他类型,如 DATETIMEDATETIMEOFFSET(带时区信息)等等.

For Date/Time, used DATETIME or SMALLDATETIME in SQL Server up to 2005, and SQL Server 2008 also offer additional types like DATE, TIME, DATETIMEOFFSET (with timezone info) and so on.

这篇关于在 SQL Server 中插入时间戳值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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