SQL Server View Designer

Source: Internet
Author: User

SQL Server often needs to write a few queries, correlate many tables, and display countless columns. If you use the View Designer, you can greatly improve efficiency and reduce errors.


1. Start the View Designer

For the database new view, the View Designer is enabled.

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/57/A3/wKioL1ShC_-A9nA6AAF91EubuhE156.jpg "title=" 1 New view. png "alt=" wkiol1shc_-a9na6aaf91eubuhe156.jpg "/>



2. Add a table

In the Start screen, the "Add Table" window will appear. Choose to add the required tables, views, functions, synonyms, and so on.

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/57/A4/wKioL1ShDN2jHDYoAALXbpyvuco477.jpg "title=" 2 Add Table- 1.png "alt=" Wkiol1shdn2jhdyoaalxbpyvuco477.jpg "/>


You can add tables or derived tables at any time in the View Designer's toolbars and right-click menus.

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/57/A4/wKioL1ShDWzheoITAALTuCeuOeg397.jpg "title=" 2 Add Table- 2.png "alt=" Wkiol1shdwzheoitaaltuceuoeg397.jpg "/>



3. Add a connection

The View Designer can automatically identify connection relationships between tables. Some connections may also need to be added manually. For example, in the Allocationroom and rooms table, the primary key is Buildingid + Roomid. Because the View Designer only adds Buildingid connections automatically, you need to manually add Roomid to the connection as well.

You can create a connection by dragging the roomid of one of the tables to the Roomid column of another table.

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/57/A7/wKiom1ShD5vBLeGWAALLNr3poAw710.jpg "title=" 3 connection-1. PNG "alt=" wkiom1shd5vblegwaallnr3poaw710.jpg "/>


The default connection is an inner join (INNER join), and if you need to modify it to a different connection relationship (left OUTER join, right OUTER join, full OUTER join, etc.), you can directly click the connection and choose Select All rows from a table.

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/57/A7/wKiom1ShEOXzFvaiAAMmotwyFco063.jpg "title=" 3 connection-2. PNG "alt=" wkiom1sheoxzfvaiaammotwyfco063.jpg "/>



4. Select columns

Select the columns you want.

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/57/A7/wKiom1ShEvLy9_TvAAHmIul6qvo712.jpg "title=" 4 columns. png "alt=" Wkiom1shevly9_tvaahmiul6qvo712.jpg "/>


If you want a column to be assigned an alias, or if you need to create a computed column, you can display the SQL pane, and then edit the T-SQL code.

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/57/A4/wKioL1ShFaTxWyRXAAOzG5How_A918.jpg "title=" 4 Modify the column. png "alt=" wkiol1shfatxwyrxaaozg5how_a918.jpg "/>


5. Preview the execution results

Execute to view the results.

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/57/A7/wKiom1ShGHqQkCJOAAQbvsUAs7o112.jpg "title=" 5 Execute the. png "alt=" wkiom1shghqqkcjoaaqbvsuas7o112.jpg "/>


6. Save the Code

If you need to save this view, save. If you don't want to save, copy the code in the SQL code pane.

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/57/A5/wKioL1ShGe6jLkFSAAMSrxXgbkw546.jpg "title=" 6 Save. png "alt=" wkiol1shge6jlkfsaamsrxxgbkw546.jpg "/>


This article is from the "We have chased the MSSQL" blog, please be sure to keep this source http://jimshu.blog.51cto.com/3171847/1597321

SQL Server View Designer

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.