SQL Server 2014 - Query Designer

The Query Designer helps you build complex queries using "point and click" without having to write all that code by hand.

In the previous lesson, we created a SQL script by clicking on New Query and running some SQL statements. In this lesson, we will look at how to write SQL scripts using the Query Designer - a GUI for building SQL statements.

About The Query Designer

The query designer is a graphical user interface that assists in building queries for your SQL Server database. This can be particularly useful when building complex queries that involves many tables, views etc.

The Query Designer can also be beneficial for those who are learning how to write SQL. By using the Query Designer to generate the SQL, you can study the SQL and learn the syntax as you go.

Building Your Queries

To build a query with the query designer, do the following:

  1. Open a new query by clicking New Query on the toolbar
  2. Open the Query Designer by selecting Query > Design Query in Editor... from the top menu:
    Accessing the Query Designer
  3. Select the tables you want to run the query against (in this case, we will add both tables), click Add, and close the box by clicking Close:
    Accessing the Query Designer
  4. Select the column/s you want to display in your query by checking the checkbox next to the column name. In the middle pane, you can deselect an Output checkbox to hide that field from being displayed when the query is run (but the field will still be involved in the query). Add a value under Filter to narrow the results down to only those you're interested in (in this example, it is creating a WHERE clause to select only those records with a StatusId of "1" - which is "To Do"):
    Query Designer
  5. Click OK once you're happy with your query.
  6. The query will appear in the query window, where you can run it the same way you run any other query (by clicking ! Execute or pressing F5)

Once you've clicked OK, you will find the query has been added to your workspace. You can then run it as you would any other query.

Screenshot of query results

But hang on to that query - don't delete it just yet. We're going to use the query to create a SQL Server view.