sql server 变量和select 赋值的联合使用demo

DECLARE @cltcode VARCHAR(30)

DECLARE @brand VARCHAR(30)

select @cltcode=cltcode,@brand=brand from prosamplehd 

CREATE table #t (

cltcode VARCHAR(30),
brand VARCHAR(30)




)

INSERT into #t  (cltcode ,brand) VALUES (@cltcode ,@brand)
select *from #t

解释:

DECLARE  定义变量后 

创建临时表,然后insert into 中插入变量的返回值, 

 

原文地址:https://www.cnblogs.com/baili-luoyun/p/11169016.html