SQL Server Management Studio Query Designer - DOTNET

SQL Server Management Studio Query Designer

Problem
When writing SQL Server queries I either need to reference an existing data model or visualize the SQL Sever tables from my database in my head in order to complete my query.  Does a visual query tool exist in the SQL Server Management Studio tool set?  If so, how can I access it and use it to streamline my SQL Server development process?  Check out this tip to learn more.
Solution
The SQL Server Management Studio ships with Query Designer which in a nutshell is a visual querying tool to build SELECT statements.  This is an add-in to the Query Window offering a means to add specific tables from a specific database to the designer.  You can see a visual representation of the tables with the referential integrity all in one screen, then build the needed query with JOINs, WHERE and\or ORDER BY clauses.

How do I access the SQL Server Management Studio Query Designer?

  1. Open SQL Server Management Studio.
  2. Select the database you want to query from in the drop down list of the SQL Editor tool bar, in our case 'BaltSSUG'.
  3. Navigate to the Query menu and select the 'Design Query in Editor...' option.  Alternatively, press Ctrl+Shift+Q.
  4. The Query Designer will load and follow the steps in next section to select the needed tables, then build and test the query.

What are the capabilities with the SQL Server Management Studio Query Designer?

  1. Select the user defined tables needed for the query.  System tables are not available as options in this tool.
SQL Server Management Studio Query Designer Table Selection
  1. Once the tables load in the top of the interface, arrange the tables so they make sense to you.  Next, select the columns that you want to use in the query as well as the alias, sort type, sort order, etc.  Notice how the T-SQL for the SELECT statement is being created and updated as columns are chosen.  Finally, press the 'OK' button and the query will then load into the original query window in SQL Server Management Studio as show in step 3.
SQL Server Management Studio Query Designer organized with tables to build a query
  1. The query as setup in step 2 will load into the original Query Editor window where the query can be executed, tested and modified to meet your needs.
Code from the SQL Server Query Designer is loaded into a SQL Server Management Studio query window for further development and testing

Can this tool help me with INSERT, UPDATE or DELETE statements?

Yes - as a matter of fact.  Just right click in the query pane and select Change Type and then the type of query desired.
SQL Server Management Studio Query Designer Supports SELECT, INSERT, UPDATE and DELETE commands
Next Steps
Copyright © 2015 DOTNET All Right Reserved