Creating a SQL query

Top  Previous  Next

Data wizard allows quickly choosing tables, contained in a data base. Creation of SQL query requires additional work. For this, press the "Add SQL query..." button in the second step of the wizard.

 

addQuery

 

You will see the query wizard window. Query wizard has four pages. Use the "Next" and "Back" buttons to switch between the pages.

 

In the first step, you need to set the name of a query. This name will appear in the "Data" window. Enter any unique name and press the "Next" button.

 

queryWizard2

 

In the second step, you have to enter a query in SQL language. Use the language dialect which is supported by your MSDB. You can use the query builder for visual query creation. To do this, press the "Query Builder" button. The query builder will be described in details later.

 

After you have entered the query text, press the "Next" button. In the third step, you can define the query parameters. It is required if your query has parameters. We will consider parameters later in this chapter.

 

On the last step of the wizard, you can set up the columns which were returned by the query:

 

queryWizard4

 

 

If you made a mistake in the query text or in the parameter definition, you will see error message when turning to the last page of the wizard.

 

As a rule, it is enough to be assured that the query has returned all the needed columns. On this step, you can do the following:

 

delete unnecessary columns using the "Delete" button;
reset the columns by pressing the "Refresh" button;
add a calculated column by pressing the "Add calculated column" button. For a new column, it is necessary to set the "Name", "DataType" and "Expression" properties.

 

After closing the wizard by pressing the "Finish" button, you will return to the "Data wizard" window.