How to Create a View in SQL Server

To create a view in SQL Server:

  1. Open a new query by clicking the New Query button in the SSMS toolbar
  2. Type or paste a CREATE VIEW statement (example below)
  3. Run the script

The view will now be created in the database. You will be able to see it under the Views node in the Object Explorer.

You can now use SELECT statements against the view in future queries.

Below are screenshots of the above steps.

Continue reading

What is a View?

In the world of databases, a view is a query that’s stored on a database.

The term can also be used to refer to the result set of a stored query.

To create a view, you write a query, then save it as a view.

To run a view, you query it, just like you’d query a table. The difference is that, the view itself is a query. So when you query the view, you’re effectively querying a query.  This enables you to save complex queries as views, then run simple queries against those views.

Continue reading