Languages
[Edit]
EN

MS SQL Server - Create or alter view

0 points
Created by:
TylerH
448

In this article, we would like to show you how to create and update a view using CREATE OR ALTER VIEW in MS SQL Server.

Quick solution:

Practical example

Edit

To show how to create or replace a view, we will use the following table:

MS SQL Server - example data used to create or replace a view
MS SQL Server - example data used to create or alter a view

Note:

At the end of this article you can find database preparation SQL queries.

Example 1 - create view

Edit

In this example, we will create a view using CREATE OR ALTER VIEW statement.

Query:

Result:

MS SQL Server - create or replace a view - result
MS SQL Server - create or alter a view - results

Example 2 - update view

Edit

In this example, we will remove the country column from the view created in Example 1. We will remove the column by updating the existing view using CREATE OR ALTER VIEW statement.

Query:

Result:

MS SQL Server - create or replace a view - result
MS SQL Server - create or alter a view - results

Database preparation

Edit

create_tables.sql file:

insert_data.sql file:

create_view.sql file:

Alternative titles

  1. MS SQL Server - Create or replace view
1
Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.

MS SQL Server - problems

MS SQL Server - Create or alter view
Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join