SQL Server: Cannot insert an explicit value into a timestamp column

后端 未结 7 2050
无人及你
无人及你 2020-11-30 09:25

When using this statement

create table demo (
    ts timestamp
)

insert into demo select current_timestamp

I get the following error:

7条回答
  •  情歌与酒
    2020-11-30 10:13

    According to MSDN, timestamp

    Is a data type that exposes automatically generated, unique binary numbers within a database. timestamp is generally used as a mechanism for version-stamping table rows. The storage size is 8 bytes. The timestamp data type is just an incrementing number and does not preserve a date or a time. To record a date or time, use a datetime data type.

    You're probably looking for the datetime data type instead.

提交回复
热议问题