Creating a Query File

Create a query (.qry) file to add a SQL statement operation to a database service.

A query file contains Select statements created by the SQL Query Editor and can be reused for other database services at any time.

  1. From the main menu bar, select File > New > Other.

    The Select a wizard dialog opens.

  2. Select Sybase, Query, and click Next.

    The Create Query File dialog opens.

  3. Specify the name and location of the query file.
  4. Do one of the following:
    • Select a connected database connection profile for the query file.
    • If no connection profile is appropriate for the query file, click New Connection Profile, click Connect to connect to the database, and click Finish to create the file.
    The SQL Query editor opens displaying a list of database tables.
  5. To create more complex SQL statements by adding and nesting clauses, do the following:
    1. Select the query file you want to include nesting and click Open With > SQL Query editor .
    2. Define the table layout. Select the columns in the list that you want to use in your table and specify the following clauses:
      Table 1. Available clauses in Visual SQL
      Clause Description
      Where Specify the rows to be affected by a select statement. Choose from the following:
      • Column
      • Operator
      • Value
      • Logical
      Compute Define additional result columns using expressions. If used with a group clause, these expressions may calculate a Summary value.
      Sort Sort queries by column in ascending or descending order.
      Group Organize groups based on repeating values in the grouping columns. Drag and drop groups from the left pane to the right pane.
      Having Specify which groups to display based on the group clause. Rows that do not meet the search conditions of that clause are excluded
      XML Currently not supported.
  6. (Optional) Preview the query and retrieval arguments:
    • Preview the query. Click inside the SQL editor and select Design > Preview from the main menu bar.
    • Add the retrieval arguments:
    1. Click inside the SQL editor and select Design > Retrieval Arguments from the main menu bar to open the Specify Retrieval Arguments dialog.
    2. Enter the argument name, select an argument type from the drop-down list, and click OK. The argument is now available for use.
  7. Select File > Save from the main menu bar.
Related concepts
Database Services
Related tasks
Specifying Retrieval Arguments in a Query File
Adding a SQL Statement Operation by Importing Query Files

Send your feedback on this help topic to Sybase Technical Publications: pubs@sybase.com

Your comments will be sent to the technical publications staff at Sybase, Inc. For product-related issues or technical support, contact Sybase Technical Support at 1-800-8SYBASE.