SELECT语句生成INSERT值
问题描述:
是可以做到这一点的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语句那样完成,我就会徘徊。
答
您可以在SQL Server中执行insert select
语句。
查询改成这样:
insert into [processing].dbinputfields ([description], fieldtypeid, datasetid)
select 'ID', id, 6
from [processing].dbfieldtype
where description = 'URN'