On my previous blog post, I demonstrated how to use an SQL statement to create a view. On this post, I want to show how to create a view using the graphical Explorer feature of SQL server. The first step is to open Object Explorer from under View.
Expand the Databases folder and then expand Adventure works until you can see the view folder. Right click on the view folder and click on "New View"
Select the tables that you want to use in your view. In this example I will use the highlighted tebles in the screenshot below.
Push the Add button and you will arrive at a screen similar to the one below.
The screen below is made up of four panes:
1) The top pane, which is called the canvas pane, shows our two tables and their relationship. 2) The second pane from the top shows the information about columns in the two tables. This is where we must select the columns which we want to be used in the view. Column aliases could also be added especially if the two tables have columns which share the same name (See the screenshot below and how I selected aliases for the Modified Date). 3) The third pane shows information about the select statement. This statement has ben automatically generated and could also be altered manually if needed. This SQL statement could be further modified if need (e.g. adding order by or filtering) 4) The bottom pane is where the results of a select statement are displayed.
After existing the view Microsoft SQL Server asks if you want to save it. Puch Yes.
Select a name for the view and push OK. Note that this new view will not immediately appear under the view folder. The folder will need to be refreshed in order for it to appear.
0 Comments
Leave a Reply. |
CategoriesArchives
June 2020
|