--查找空间名、物理空间路径
SELECT name, physical_name
FROM sys.master_files
WHERE database_id = DB_ID('tempdb');
可以执行以下脚本批量执行
---临时表数量查询
select COUNT(1) from sys.tables u
join T_BAS_TEMPORARYTABLENAME v on u.name=v.FTABLENAME and
( v.FPROCESSTYPE=1 or v.FCREATEDATE<GETDATE()-1)
--删除(一次性全部删除可能会花很长时间,建议分批删除,top 1000 表示该批删除1000个表)
declare @sql as varchar(max)
set @sql=''
select @sql=@sql+'drop table '+name+';' from
(select top 1000 name from sys.tables u
join T_BAS_TEMPORARYTABLENAME v on u.name=v.FTABLENAME and
( v.FPROCESSTYPE=1 or v.FCREATEDATE<GETDATE()-1)) T;
exec(@sql);
delete u from T_BAS_TEMPORARYTABLENAME u where
not exists(select 1 from sys.tables where u.ftablename=name );
临时表删除后收缩账套以释放空间。