/*******************************************************************************************************************
-- Title : [SQL2016] DROP ~ IF EXISTS 사례
-- Reference : microsoft.com
-- Key word : drop if exists drop table if exists
*******************************************************************************************************************/
use tempdb;
go
/*
-- DIE(Drop If Exists) : 존재하면 지우고 없으면 그냥 Continue.
-- 왠만하면 테스트 스크립트에서만 쓰자.
*/
-- 테이블 생성
create table ttt(a int, b int);
insert into ttt select 1,1;
insert into ttt select 2,2;
-- 테이블 생성 확인
select * from sys.tables
-- drop if exists 수행
drop table if exists ttt;
-- 테이블 제거 확인
select * from sys.tables
-- 없는 테이블 제거
drop table if exists ttt73655949; -- 아무 에러 없음
-- drop ~ if exists 트리거
DROP TRIGGER IF EXISTS trProductInsert
-- 사용 가능 오브젝트