declare @i int
SELECT ItemCode,Sum(Quantity*Price) jg
Into #Temp_1
From Rdr1
Group By ItemCode
select @i=1
while @i<=3
begin
Insert Into #Temp_1 Values('aaa',1)
select @i=@i+1
end
SELECT ItemCode,Sum(Quantity*Price) jg
Into #Temp_1
From Rdr1
Group By ItemCode
select @i=1
while @i<=3
begin
Insert Into #Temp_1 Values('aaa',1)
select @i=@i+1
end
Select * From #Temp_1
本文通过一个具体的SQL示例介绍了如何使用T-SQL创建临时表,并演示了如何利用循环进行数据插入操作。此外,还展示了如何从源表中按物品代码分组汇总数据并将其插入到临时表中。
981

被折叠的 条评论
为什么被折叠?



