DROP IF EXISTS with multiple tables

SQL Server 2016 has introduced new DDL statement DROP IF EXISTS which will drop the table if exists.

In my earlier post on Dropping multiple tables with one DROP statement I have shown the method on how you can use single DROP statement to drop multiple tables

In the similar way, the new DDL also supports dropping multiple tables if they exists

create table #t1(id int);
create table #t2(id int);
create table #t3(id int);

DROP TABLE IF EXISTS #t1, #t2, #t3

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s