SQL Server Management Studio Query Designer
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.
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?
- Open SQL Server Management Studio.
- Select the database you want to query from in the drop down list of the SQL Editor tool bar, in our case 'BaltSSUG'.
- Navigate to the Query menu and select the 'Design Query in Editor...' option. Alternatively, press Ctrl+Shift+Q.
- 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?
- Select the user defined tables needed for the query. System tables are not available as options in this tool.
- 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.
- 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.
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.
- The next time you are having a hard time pulling your query together, consider the Query Designer. Many developers and DBAs are visual and this tool serves them well to get started and stay productive.
- As you begin to work with developers and DBAs new to SQL Server, let them know about the Query Designer and show them how it can help them get off the ground.
- Consider the Query Designer in addition to the visual data modeling tools in SQL Server Management Studio when you are starting to work with a new system or just can not remember the data model on a large system.
- Based on initial research, the Query Designer is available from the SQL Server Express to Enterprise editions.
- Check out these related tips on MSSQLTips.com:
About the author
View all my tips
Article Last Updated: 2013-01-23