Showing posts with label Query Designer. Show all posts
Showing posts with label Query Designer. Show all posts

Saturday, March 21, 2015

How do you design a Query using Query Editor in SQL Server Management Studio?

From scratch:
Open a Query pane in SSMS (from a database, for example) and right click to display the drop-down menu as shown.

DesignQueryinEditor

Choose the Design Query in Editor... option and the Query Designer window gets displayed with a Add Tables window. You can add as many or as few tables as you want and design your query. Holding control key down, select multiple tables and click ADD to add all the selected tables. If you suspect that the data has changed recently, you can click Refresh to use latest data.

DesignQueryinEditor2

Display a query you created in the designer

You can create a query in the query pane. Highlight the query, right click the highlighted portion and select Design Query in Editor... as shown.


QueryEditorUp
The query you designed gets displayed in the Query Editor as shown.

SimpleSelect
 Selecting the query and displaying it in designer will not work for more complicated queries.


Saturday, December 14, 2013

How do I bring up the query designer in SQL Server 2012 Express?

Query Designer is a Graphic User Interface.

It is quite easy.
There are two ways you can do it.

Step 1. Open a Query pane by right clicking either the Server Node or right clicking one
of the user databases as shown.
 SERVER NODE


USER DATABASE NODE

Step 2. Once the query pane is open, click inside the query pane. The main menu
changes
to display the Query menu item as shown.

 


Step 3.Click Query menu item to display a drop-down list and click on Design Query in Editor or Ctrl+Shift+Q
 

This should bring up the designer as shown.


Step 3b. Another way is to right click inside the query pane and choose Design Query in Editor as before.

 

Thursday, June 18, 2009

How do I create a simple table in a database on SQL Server 2008 and populate it?

Let us say you want to create a table such as the one shown in this example (PrincetonTemp2) and populate it with some values. There is more than one way to create a table in SQL Server 2008.This one uses Create Table query to create a table. You then edit the table to insert the values. Values can also be inserted using code. In here, the query creates the table and you then manually insert the data.

Step 1: Create table using the query
In SQL Server 2008 right click the database in which you want to create a table and choose New Query






Type in the Query window as shown in the next figure. Check the syntax of the query by clicking the icon at the far right of the figure. Execute the query by clicking the (!)Execute.








You will have created a table called PrincetonTemp2. You can see it in the Tables node after you refresh the database by right clicking the database node and choosing Refresh from the list.

Step 2: Populate the table by editing the table :
Right click the table in the Management Studio after expanding the database node.










From the drop-down click on Edit Top 200 Rows.
In the table that shows up fill in the data you want to insert. The data has to match the query you used to create the table. One line inserted is shown in the next figure.


Thursday, October 9, 2008

How do you use the Query Designer in SQL Server 2008?

Well, there are a few steps you need to follow. This note shows how you may create and execute a query in the SQL Server Management Studio. I am using a copy of the Northwind database.

Step 1:

Click on New Query toolbar item [directly below File in SQL Server Management Studio]

Step 2:

In the new empty query created [herein SQLQuery1.sql - Hodentek2\...]. Right click on an empty area and choose Design Query in Editor





















Query Designer pops-up with the Add Table modal window on top of it as shown.























Step 3:

Hold down Control Key and highlight Products and Suppliers in the Add table list and click on the Add button. After the tables are added close the window.

The Tables get added to the Query Designer together with the relationship between them as shown.











Step 4:

Place check marks for the columns in Products and Suppliers as shown.
You do not need to do anything with the Grid Pane or the SQL Pane below it. Just observe them as you place the check marks.















Step 5:

Execute the query in the designer and if you are satisfied click OK.
The SQL Statement gets in to the Query window.
Study the SQL Statement.

You are done!!
You successfully used the Query Editor to query two tables in the database.