From the course: Complete Guide to Advanced SQL Server

Unlock the full course today

Join today to access over 24,400 courses taught by industry experts.

Save a query as a view object

Save a query as a view object

When the development of your database moves beyond the basic structure of the tables and relationships, the first additional object that's generally created is a view. Views are essentially saved SELECT queries, and they return virtual tables that display attribute columns and rows of data from your main database tables. Views don't generally store data themselves. Instead, they fetch the current state of the data from the requested tables every time the view is called. So there's no need to keep them updated or maintained as the data that you're storing changes. If you can write a SELECT query, then you can create a view. Let's take a look by exploring the contact details for the suppliers that Wide World Importers uses. On Line Number 2, I'm going to make sure that we're targeting this to the Wide World Importers database, and then we're going to run three SELECT statements. The first one pulls a single row from the Purchasing.Suppliers table. Then we'll get related details from…

Contents