表变量,临时表


--
表变量 update invent set goodInfo=null declare @tmp_goods table( gno char(5) ) insert into @tmp_goods select gno from invent group by gno declare @gno char(6),@stno char(6),@gname varchar(255),@producer varchar(255) while exists(select gno from @tmp_goods) begin set rowcount 1 select @gno=gno from @tmp_goods select @gname=gname,@producer=producer from goods where gno=@gno; set rowcount 0 update invent set goodInfo=@gname+'-'+@producer where gno=@gno delete from @tmp_goods where gno=@gno end select * from invent
--临时表  放在dbtemp数据库中
if OBJECT_ID('tempdb.dbo.#tmp_inv','U') is not null
drop table #tmp_invent

方法1:
create table #tmp_inv(id int)
--方法2
select * into #tmp_inv from invent
原文地址:https://www.cnblogs.com/zhuxiang1633/p/7754509.html