Enhanced DML and DDL statements
In this section, you will explore enhancements in Data Manipulation Language (DML) and Data Definition Language (DDL) that are not part of new features or improved features from previous SQL Server versions.
The section starts with a small syntax extension that you will use often in the code examples in this book.
The conditional DROP statement (DROP IF EXISTS)
With a conditional DROP
statement, you can avoid getting an exception if the object you want to drop does not exist. If, for instance, the T1
table has already been removed or it was not created at all, the following statement will fail:
DROP TABLE dbo.T1;
Here is the error message:
Msg 3701, Level 11, State 5, Line 5 Cannot drop the table 'dbo.T1', because it ...
Get SQL Server 2016 Developer's Guide now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.