Little SQL Server Tricks: CREATE OR ALTER Views
With SQL Server 2016 SP1 came a small but helpful new statement to create views: OR ALTER. If you add this to the create script for a view, SQL Server will figure out if it should run the CREATE or the ALTER statement:
1 2 3 4 5 6 7 8 9 10 11 |
CREATE OR ALTER VIEW EmployeeReport AS SELECT p.FirstName, p.MiddleName, p.LastName, e.HireDate, e.JobTitle FROM Person.Person p JOIN HumanResources.Employee e ON p.BusinessEntityID = e.BusinessEntityID |
This feature is especially helpful when you incrementally develop your views. …