Using CREATE or ALTER View in SQL Server

Using CREATE or ALTER View in SQL Server
Using CREATE or ALTER View in SQL Server

Hello everyone. In this article, I will try to give information about Using CREATE or ALTER View in SQL Server.

There is a small but useful new feature for creating Views with SQL Server 2016 SP1. OR ALTER statement. If you add this statement to your code to create the View, SQL Server will know whether it needs to run a CREATE or ALTER statement.

Below you can see a Vew example created for the Adventureworks database.

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 useful when gradually developing your Views. You can focus on the change in View and no need to switch between CREATE and ALTER.

Good luck to everyone in business and life.

16 Views

Yavuz Selim Kart

I try to explain what I know in software and database. I am still improving myself by doing research on many programming languages. Apart from these, I am also interested in Graphic Design and Wordpress. I also have knowledge about SEO and Social media management. In short, I am a determined person who likes to work hard.

You may also like...

Don`t copy text!