declare @sql varchar(100)
CREATE TABLE #b (a VARCHAR(30))
set @sql='insert into #b select pcode from pdata '
--print @sql
exec(@sql) --EXEC里面可以用外面创建的临时表
select * from #b
drop table #b
---------------------------------------------------------------------------------------
declare @sql varchar(100)
set @sql='select id as a,name as b into #b from shopName'
--print @sql
exec(@sql) --临时表#b只在EXEC执行过程中有效,在EXEC外无效
select * from #b
drop table #b