Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
CRW_REF.PDF
Скачиваний:
5
Добавлен:
13.02.2015
Размер:
13.99 Mб
Скачать

Query Designer makes it easy for you to get the information you need.

Sometimes you may need to retrieve the same data on a recurring basis (weekly, every month end, etc.). By setting up and saving a single query, you can retrieve updated data quickly, whenever you need it, with minimal effort.

NOTE: The Query Designer can not retrieve any number value larger than 20 characters or calculate a formula with a value larger than 20 characters. Values larger than 20 characters will be truncated.

HANDS-ON (Queries)

How to use an SQL query that you designed elsewhere

Copy your SQL statement to the Windows Clipboard. Many SQL editors will let you copy the SQL statement to the Clipboard using the Ctrl-C key combination.

Click the NEW button on the toolbar in the Crystal Query Designer.

The New Query dialog box appears.

3 Click the Enter SQL statement directly button.

 

 

 

470

Seagate Crystal Reports User’s Guide

"Select the desired SQL server for your SQL statement, and click OK. The SQL Server Login dialog box appears.

#Enter your user ID and password to log on to the SQL server, and click OK.

$After a message appears indicating the success of your log on (assuming you logged on correctly) the Enter SQL Statement dialog box appears.

7 Specify the ODBC data source from this drop-down box.

8 If you are not already logged on to an SQL Server, click the Log On Server button and log on using the Log On Server dialog box.

'If you need to log on to another server or ODBC data source, click the Log On Server button. All data sources that you are logged on to will appear in the Data Source drop-down box.

Use the Title text box to give a title to your query that describes its purpose.

Enter your SQL statement in the large SQL edit box. Click anywhere inside the box to place an insertion point.

Press Ctrl-V or click the Paste button in the dialog box to paste your SQL statement into the SQL edit box.

Queries

471

Edit your SQL query in this box.

Paste button.

! The SQL edit box allows you to make any changes you wish to your SQL statement. You can even enter an entirely new SQL statement if you wish. Make any changes you need and click the OK button when you are finished.

Your old SQL statement becomes a new SQL query that can be used with Seagate Crystal Reports just like any other SQL query file.

Alternatively, you can import an SQL statement saved in an ASCII text file. To do so, disregard Step 1 above, follow Steps 2 through 6 to open the Enter SQL Statement dialog box and log on to the ODBC data source, then click Import to import the SQL statement from the text file.

How to create a new query

Click the NEW button in the Crystal Query Designer. The New Query dialog box appears.

472

Seagate Crystal Reports User’s Guide

2 Click the Use Crystal Query Expert button.

The Create Query Expert consists of several tabs. The tabs are numbered to lead you step-by-step through the query creation process.

NOTE: The Links Tab only appears if you select two or more database tables on the Tables Tab.

The remaining sections in this chapter explain how to perform specific tasks with the Crystal Query Designer.

NOTE: Once you select at least one field for the query on the Fields Tab, you can view the data retrieved by your query at any time, by clicking the Preview Query button at the bottom of the

dialog box. After you are done viewing the query data, use the Edit button to return to the Query Expert.

How to add tables to a query

Generates FROM clause

The FROM clause specifies the sources (tables) of the database fields indicated in the SELECT statement.

Click the Tables Tab in the Crystal Query Expert.

Queries

473

Соседние файлы в предмете [НЕСОРТИРОВАННОЕ]