我创建了临时表并存储了客户的ID。
现在我想从临时表的id中获取客户名,同时将其插入另一个表中。
Insert INTO Cust1 Values(Id, Name)
Values SELECT ID From @Temp (here from the specific id i want to insert the name.)
提前致谢
答案 0 :(得分:0)
如果没有错,你只需要简单的INSERT from SELECT
。过滤ID
子句中的Where
Insert INTO Cust1 Values(Id, Name)
SELECT ID,Name From @Temp Where ID = --your id
答案 1 :(得分:0)
使用insert . . . select
。据推测,您需要在其他表中查找名称:
insert into Cust1 (Id, Name)
select t.ID, o.name
from @Temp t join
othertablehere o
on t.id = o.id;
答案 2 :(得分:0)
插入INTO Cust1值(Id,Name) 值SELECT ID,cust.name来自@Temp temp,customers cust where top.itop.IDtop.itop.ID = cust.Id