1.临时表
判断临时表是否存在如果存在删除
if exists(select * from tempdb..sysobjects where id=object_id(‘tempdb..#temp’))
创建临时表
create table #temp(
id int
)
使用临时表
select id from #temp
删除临时表
drop table #temp
注:虽然SQL Server 有断开链接自动删除临时表的机制,但是要养成习惯最后临时表使用完毕还有要删除