2015-09-28 130 views
0

是可以做到这一点的SQL即使用SELECT语句生成INSERT值:SELECT语句生成INSERT值

insert into [processing].dbinputfields ([description], fieldtypeid, datasetid) 
values ('ID', + select id from [processing].dbfieldtype where description='URN' + ,6) 

我知道我可以ID的值赋值给一个变量(@ID )。但是,如果可以像上面的SQL语句那样完成,我就会徘徊。

回答

2

您可以在SQL Server中执行insert select语句。

查询改成这样:

insert into [processing].dbinputfields ([description], fieldtypeid, datasetid) 
select 'ID', id, 6 
from [processing].dbfieldtype 
where description = 'URN'