SQL Server 2K - 为时间戳列插入显式值? [英] SQL Server 2K - Insert explicit value for timestamp column?

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

问题描述

我目前正在从事一个项目,我需要将数据(通过一些小的转换)从一个数据库传输到另一个数据库.当我点击我的第一个时间戳列时,一切都很好......

I'm curently working on a project where I need to transfer data (with some minor transformations) from one database to another. Everything was going just fine when I hit my first Timestamp column...

似乎 SQL Server 不希望我为这种类型的列使用显式值,而是希望生成自己的值.

It seems SQL Server doesn't want me to use explicit values for this type of column and it, instead, wants to generate its own.

如果有办法,使用 T-SQL,我可以将这些数据从一个表获取到另一个表?

If there a way, using T-SQL, I can get this data from one table to another?

推荐答案

注意:名称时间戳已被弃用,新的​​(更准确的)名称是 rowversion.

Note: The name timestamp is deprecated, the new (and more accurate) name is rowversion.

两个答案:

否:行版本类型的 SQL Server 列始终由数据库服务器生成和设置.

No: SQL Server columns of type rowversion are always generated and set by the database server.

是:如果您在目标表中使用不同的数据类型.从 rowversion 列读取的值可以存储在 varbinary 列中.因此,您可以在新表中创建一个 varbinary 列来保存旧表中的值.当然,这个 varbinary 列不会像 rowversion 列那样自动更新.

Yes: If you use a different datatype in the target table. The values read from a rowversion column can be stored in a varbinary column. So you could create a varbinary column in the new table to hold the values from the old table. Of course, going forward this varbinary column would not get updated automatically like a rowversion column would.

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

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