【发布时间】:2010-09-28 17:48:40
【问题描述】:
我公司最近进行了一次数据迁移(在 SQL Server 2005 数据库中),我们注意到使用 SELECT INTO 创建的一些表没有维护原始表的计算字段,而是 SQL Server 创建了具有类型的常规字段由原始计算返回。例如,假设您有这张表:
create table Example (
id int not null,
quantity decimal(19,5) not null,
price decimal(19,5) not null,
total as price*quantity
)
在执行 SELECT * INTO Example2 FROM Example 后,您会得到:
create table Example2 (
id int not null,
quantity decimal(19,5) not null,
price decimal(19,5) not null,
total decimal(38,9) null
)
我修复了它删除坏字段并重新创建它们,但我想知道是否有一种方法可以维护使用 SELECT INTO 创建的表中的计算字段(可能使用一些特殊的 SQL Server 配置或使用替代 SQL命令)。
提前致谢。
【问题讨论】:
标签: sql-server calculated-columns select-into