sql临时表建立和使用

sql临时表建立和使用


SET STATISTICS TIME ON --开启时间信息
drop table #temp  --删除已存在临时表(断开连接时自动删除)
select * into #temp from orders order by orderdate  --建立临时表
select * from #temp  --查询临时表

#table  是在当前数据库中
##table  是在全局的数据库中
跨库使用格式:  数据库名.dbo.表名

原文地址:https://www.cnblogs.com/sgivee/p/1858821.html