DIE statements in SQL Server 2016
SQL Server 2016 is going to be released soon (no, I don't know the date, either. Update: June the 1st 2016, it was. Happy we were). I will publish some posts about my favourites over the next months.
DIE (Drop If Exists) statements is syntactic sugar to the T-SQL language to make it easier to make repeatable scripts.
DROP TABLE IF EXISTS <TABLENAME>
will drop table <TABLENAME> if it exists and will not return an error if it doesn't. Nice. DIE statements will work for a lot of database objects like
to name a few.
Now, if I could make a wish or two then it would have been even nicer and human readable if the syntax had been DROP TABLE <TABLENAME> IF EXISTS, (but I can live with the syntax when I no longer need to ask if OBJECT_ID is null.). And since other RDBMS products (Oracle, MySQL and PostgreSQL) already have implemented the syntax DROP TABLE IF EXISTS <TABLENAME>, then I guess Microsoft will stick with that (thanks Aron Bertrand for pointing that out).
Aron also mentioned that there exists numerous connect tickets about this. Please vote here
and let's remind Microsoft that we want this syntax in T-SQL.
I still miss the syntactic sugar from PL/SQL, where I can write
CREATE OR REPLACE
for objects like views, functions and procedures. Since the PL/SQL syntax was derived from he ADA language, I don't think Microsoft will be in too much trouble adapting that. But you never know.