是否有更好的方法在 Azure SQL 上删除临时表?
BEGIN TRY
DROP TABLE #customMap
END TRY
BEGIN CATCH
END CATCH
也许不需要删除 Azure SQL 上的临时表,因为 session 结束时表会被删除。
这个
if (OBJECT_ID('#candidates')) is not null
begin
drop table #candidates;
end;
或者这个
if (OBJECT_ID('tempdb..#candidates')) is not null
begin
drop table #candidates;
end;
不起作用。
最佳答案
在 Azure SQL 数据库中,您可以使用 DROP IF EXISTS (DIE) 语法:
create table #temp (id int)
drop table if exists #temp
关于sql - 删除临时表(如果 SQL Azure 上存在),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30531728/