IF (SELECT object_id('TempDB.#jobsconsumed')) IS NULL
BEGIN
DROP Table #jobsconsumed
END
上記のコードは必要はありません正しい方法は
IF object_id('Tempdb..#test') is Not null
is same as
IF object_id('Tempdb.dbo.#test') is Not null
Drop Table #test
を下回っている、TempTableのを確認し、ドロップし
に... TempTableのが存在する場合にのみ、句を開始入りますこの例では、Begin End句とEND句は、真のときにIFが即時ステートメントを実行するため、
TEMPテーブルのスキーマの側面に関する青梅テスト..
use tempdb;
create schema hr
create table hr.#t(c int) --this will work
create table #t(c int) --this will fail
create table #t1 --no schema ,so it will create a temp table in DBO Schema by default.
--To drop the table
drop table #t --this will drop across all schemas
は、私はあなたが2個のドットを試みるべきだと思う: 'のTempDB ..#jobsconsumed' – HoneyBadger
2つのドットは何をしますか? – whatwhatwhat
おそらく 'IS NOT NULL'は本当に必要なロジックです。存在しないものを削除するのはなぜですか? –