Creating a View Visually in SQL Server 2012

In this article, we will see how to create a view visually in SQL Server 2012. View is defined as a virtual table with data from various tables in the database. Views are most commonly used to provide security because it ensures that a user can only access the data they are intended to access and any remaining data is neither seen nor can be accessed by them. The remaining data is thereby automatically protected from unwanted users. So let's take a look at a practical example. The example is developed in SQL Server 2012 using the SQL Server Management Studio.

To visually create a view

Now Press F8 to open the Object Browser in SQL Server Management Studio and expend it.

Database -> View -> right-click-> select New View

Create-view-in-sqlserver.jpg

This would open the "Add table" window:

Add-tables-in-sqlserver.jpg

Now In the preceding add table window, select a table of your choice to create a view. Now select table name -> click on the add Button "Add table" window. Selecting tables looks as in the following: 

Selected-tables--in-sqlserver.jpg

As you can see we have no relations among the available tables. We can relate the tables by selecting the column from one table to another table.

View-Result-in-sqlserver.jpg

Now right-click on the query window -> select execute.

Select-Execute-option-in-sqlserver.jpg

Now click on the Execute to see the result.

View-Result-in-sqlserver.jpg


Similar Articles