Home » Microsoft SQL Server » 07 - Complex Queries and Views
7
A View through the Management Studio GUI
The basics of management studio GUI
- Delete the bookinfo view under the 'Views' folder by right clicking on it and clicking delete. Confirm your choice and make sure that the view does not exist.
- Right click on the 'Views' Folder and click 'New View...'
- Hold down the shift key and click on the author, book, and subject tables. Click on the 'Add' button
- Now, click the 'close' button.
- The resultant Query designer dialogue should resemble the following screen shot. The designer automatically performs joins on foreign keys in included tables.
- First, scroll to the 'table' column of the first row. Select 'book'.
- Now, scroll to the 'Column' field for this row and select 'title' from the list.
- Select 'Ascending' in sort type and enter '1' under order.
- Copy the following string into the 'Column' field of the next row:
dbo.author.lastname + ', ' + dbo.author.firstname
- Enter 'Author' under Alias.
- Select 'Ascending' in sort type and enter '2' under order.
- Scroll to the 'table' column of the third row. Select 'subject'.
- Select 'subjectdesc' from the list in the leftmost 'Column' field.
- Select 'Ascending' in sort type and enter '3' under order. Following is the resultant screenshot:
- Note that the T-SQL for the view is displayed in the bottom window. Right click on the View tab and click on 'Save View..'. Enter 'bookinfo' in the popup window and click 'OK'. You have now created the view through the GUI. You may test your view by issuing a 'select * from bookinfo' command.
