我在一個名爲#tempIQ的臨時表中有幾個值,並且我想使用相同的組標識符插入名爲IQGroups的表中。假設每個人都有獨特的智商:在臨時表中插入幾個值
create table #tempIQ
(
id int
)
declare @GroupIDas int
set @GroupID=1001
select iq from #tempIQ
1,2,86,99,101,165,180,201
我想從臨時表中這些ID插入一組名爲IQGroups但我很難找到一個簡單的解決方案。
-- now try and insert all the iqs for a group into the IQGroups table from the #tempIQ table.
insert into IQGroups (GroupID, IQ) values (@GroupID, #tempiQ.iq)