0

我刚刚创建了这张表:

create table dbo.OrderTypes
(
ID smallint primary key identity,
Name varchar(300) not null,
CreatedOn datetime default getdate(),
CreatedBy nvarchar(300) not null,
ModifiedOn datetime default getdate(),
ModifiedBy nvarchar(300) not null
)

我要做的是使用此查询的结果填充名称字段:

select distinct ordertype from unit_results

以及手动插入 CreatedBy 和 ModifiedBy (它们对于每一行都是相同的)。

我该怎么做呢?

4

1 回答 1

2
INSERT INTO dbo.OrderTypes (Name, CreatedBy, ModifiedBy)
SELECT DISTINCT ordertype, 'CreatedBy Value Here', 'ModifiedBy Value Here'
FROM unit_results
于 2012-07-05T20:09:21.817 回答