When conditionally dropping non-temp tables, the typical syntax is this (with a single period between schema and table):
IF OBJECT_ID('@cohort_database_schema.@cohort_inclusion_table', 'U') IS NOT NULL
DROP TABLE @cohort_database_schema.@cohort_inclusion_table;
Similarly, when creating tables that do not exist, the typical syntax uses a single period:
IF OBJECT_ID('@results_schema.ir_strata', 'U') IS NULL
CREATE TABLE @results_schema.ir_strata( ...
However, for the majority of the queries that drop temp tables, two periods are used after tempdb
:
IF OBJECT_ID('tempdb..#cov_ref', 'U') IS NOT NULL
DROP TABLE #cov_ref;
What is the preferred syntax? Do both single and double periods syntax work on all databases?