SQL Server 2016 – DROP TABLE IF EXISTS

With the new version of Community Technology Preview 3 of SQL Server 2016 we have a new T-SQL command

DROP TABLE IF EXISTS <tablename>


This is a fantastic yet simple addition, easier to read and remember.


Other statements are supported also, see below;

[CTP 3.0] New DROP IF syntax is added for drop statements related to AGGREGATE, ASSEMBLY, COLUMN, CONSTRAINT, DATABASE, DEFAULT, FUNCTION, INDEX, PROCEDURE, ROLE, RULE, SCHEMA, SECURITY POLICY, SEQUENCE, SYNONYM, TABLE, TRIGGER, TYPE, USER, and VIEW. See individual syntax topics for syntax.

https://msdn.microsoft.com/en-us/library/bb510411.aspx#TSQL

SQL Server 2016 – DROP TABLE IF EXISTS

Leave a Reply

Your email address will not be published.

Pin It on Pinterest