SQL SERVER 临时表

发布时间 2023-12-26 10:51:26作者: microsoft-zhcn
创建临时表
方法一:
reate table #临时表名(字段1 约束条件,字段2 约束条件,.....)

方法二:
select * into #临时表名 from 表名;

查询临时表
select * from #临时表名;

删除临时表
drop table #临时表名;

判断临时表是否存在,存在则删除
if object_id('tempdb..#临时表名') is not null
begin
drop table #临时表名;
end