SQL server中使用临时表存储数据

将查询出来的数据直接用“INTO #临时表名称”的方式完成临时表的创建及数据的插入

SELECT * INTO #temp_NowStatus
FROM Test

SELECT * FROM #temp_NowStatus --查询临时表中的数据
truncate table #temp_NowStatus --清除临时表中的数据
--删除临时表
if object_id('tempdb..#temp_NowStatus') is not null BEGIN
drop table #temp_NowStatus
END

原文地址:https://www.cnblogs.com/stevenjson/p/3920312.html