0% found this document useful (0 votes)
91 views

Sybase SQL Adv

Sybase SQL Adv
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
91 views

Sybase SQL Adv

Sybase SQL Adv
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 102

SQL Advantage Users Guide

SQL Advantage 11.0.x Document ID: 32116-01-1100-02 Last Revised: August 30, 1996

Principal author: Warren Charing Document ID: 32116-01-1100 This publication pertains to SQL Advantage 11.0.x of the Sybase database management software and to any subsequent release until otherwise indicated in new editions or technical notes. Information in this document is subject to change without notice. The software described herein is furnished under a license agreement, and it may be used or copied only in accordance with the terms of that agreement.

Document Orders
To order additional documents, U.S. and Canadian customers should call Customer Fulllment at (800) 685-8225, fax (617) 229-9845. Customers in other countries with a U.S. license agreement may contact Customer Fulllment via the above fax number. All other international customers should contact their Sybase subsidiary or local distributor. Upgrades are provided only at regularly scheduled software release dates. Copyright 19891996 by Sybase, Inc. All rights reserved. Portions of the software Copyright 1994, Lifeboat Publishing. Portions of the software Copyright 1996, Rogue Wave Software Inc. No part of this publication may be reproduced, transmitted, or translated in any form or by any means, electronic, mechanical, manual, optical, or otherwise, without the prior written permission of Sybase, Inc.

Sybase Trademarks
Sybase, the Sybase logo, APT-FORMS, Data Workbench, DBA Companion, Deft, GainExposure, Gain Momentum, Navigation Server, PowerBuilder, Powersoft, Replication Server, S-Designor, SQL Advantage, SQL Debug, SQL SMART, SQL Solutions, SQR, Transact-SQL, and VQL are registered trademarks of Sybase, Inc. ADA Workbench, AnswerBase, Application Manager, APT-Build, APT-Edit, APT-Execute, APT-Library, APT-Translator, APT Workbench, Backup Server, BitWise, Client-Library, Congurator, Connection Manager, Database Analyzer, DBA Companion Application Manager, DBA Companion Resource Manager, DB-Library, Deft Analyst, Deft Designer, Deft Educational, Deft Professional, Deft Trial, Developers Workbench, DirectCONNECT, Easy SQR, Embedded SQL, EMS, Enterprise Builder, Enterprise Client/Server, Enterprise CONNECT, Enterprise Manager, Enterprise SQL Server Manager, Enterprise Work Architecture, Enterprise Work Designer, Enterprise Work Modeler, EWA, ExElerator, Gain Interplay, Gateway Manager, InfoMaker, Interactive Quality Accelerator, Intermedia Server, Maintenance Express, MAP, MDI, MDI Access Server, MDI Database Gateway, MethodSet, Movedb, Navigation Server Manager, NetGateway, Net-Library, New Media Studio, ObjectCONNECT, OmniCONNECT, OmniSQL Access Module, OmniSQL Gateway, OmniSQL Server, OmniSQL Toolkit, Open Client, Open Client CONNECT, Open Client/Server, Open

Client/Server Interfaces, Open Gateway, Open Server, Open Server CONNECT, Open Solutions, PC APT-Execute, PC DB-Net, PC Net Library, Powersoft Portfolio, Powersoft Professional, Replication Agent, Replication Driver, Replication Server Manager, Report-Execute, Report Workbench, Resource Manager, RW-DisplayLib, RW-Library, SAFE, SDF, Secure SQL Server, Secure SQL Toolset, SKILS, SQL Anywhere, SQL Code Checker, SQL Edit, SQL Edit/TPU, SQL Server, SQL Server/CFT, SQL Server/DBM, SQL Server Manager, SQL Server Monitor, SQL Station, SQL Toolset, SQR Developers Kit, SQR Execute, SQR Toolkit, SQR Workbench, Sybase Client/Server Interfaces, Sybase Gateways, Sybase Intermedia, Sybase Interplay, Sybase IQ, Sybase MPP, Sybase SQL Desktop, Sybase SQL Lifecycle, Sybase SQL Workgroup, Sybase Synergy Program, Sybase Virtual Server Architecture, Sybase User Workbench, SyBooks, System 10, System 11, the System XI logo, Tabular Data Stream, Warehouse WORKS, Watcom SQL, web.sql, WebSights, WorkGroup SQL Server, XA-Library, and XA-Server are trademarks of Sybase, Inc. All other company and product names used herein may be trademarks or registered trademarks of their respective companies.

Restricted Rights
Use, duplication, or disclosure by the government is subject to the restrictions set forth in subparagraph (c)(1)(ii) of DFARS 52.227-7013 for the DOD and as set forth in FAR 52.227-19(a)-(d) for civilian agencies. Sybase, Inc., 6475 Christie Avenue, Emeryville, CA 94608.

Table of Contents
Audience. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xi How to Use This Book . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xi Related Documents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xi Other Sources of Information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xii Conventions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xii Style Conventions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xii Privileges . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xii Mouse Buttons . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xiii Screen Images . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xiii If You Need Help . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xiii

1. Introduction
Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-1 SQL Advantage Session Windows. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-1 About Menus. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-3 Application Window Control Menu . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-3 Main Menu Bar . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-4 File Menu. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-4 Edit Menu . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-8 View Menu . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-9 Server Menu . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-11 Query Menu . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-11 Window Menu . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-12 Help Menu . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-13 Toolbar . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-13 Toolbar Microhelp . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-14 Application Window Minimize Control . . . . . . . . . . . . . . . . . . . . . . . . . . 1-15 Application Window Maximize Control. . . . . . . . . . . . . . . . . . . . . . . . . . 1-16 Application Window Restore Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-16 Session Window Control Menu . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-16 Session Window Minimize Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-17 Session Window Maximize Control. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-17 Session Window Restore Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-17 Session Window Status Bar . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-17 Application Window Status Bar . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-18 SQL Advantage Result Windows . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-18 Result Window Controls . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-19

SQL Advantage Users Guide

SQL Advantage 11.0.x

Text Output Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Multiple Text Result Windows. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Single Text Result Window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Grid Output Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

1-19 1-19 1-20 1-21

2. Using SQL Advantage


Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-1 Starting SQL Advantage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-1 Starting SQL Advantage on Windows NT 3.51 . . . . . . . . . . . . . . . . . . . . . 2-1 Starting from Icon . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-1 Starting from Command Line . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-1 Starting SQL Advantage on Windows 95 . . . . . . . . . . . . . . . . . . . . . . . . . . 2-2 Starting from Start Menu . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-2 Starting from Icon . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-2 Starting from Command Line . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-3 Setting Preferences. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-3 Setting Query Preferences . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-4 Setting Connection Preferences . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-6 Setting Result Preferences . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-7 Setting Miscellaneous Preferences . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-10 Connecting to SQL Server. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-11 Indication of Successful Connection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-15 Multiple Connections. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-15 Disconnecting from SQL Server . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-15 Using Session Windows . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-16 Creating Query Windows . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-17 Opening a Script File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-17 Loading a Script File. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-19 Connecting to a SQL Server and a Database . . . . . . . . . . . . . . . . . . . . . . 2-20 Changing Database . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-21 Editing Scripts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-21 Navigating Windows. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-21 Selecting Text . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-22 Cutting, Copying, and Pasting Text . . . . . . . . . . . . . . . . . . . . . . . . . . 2-22 Clearing Text . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-22 Undoing Last Text Edit Operation. . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-23 Finding Text . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-23 Finding and Replacing Text . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-24 Changing Fonts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-26 Executing Scripts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-27 Executing Batch Scripts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-27

vi

SQL Advantage 11.0.x

Executing Selected Text . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Executing Stored Procedures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Cancelling Execution of a Script . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Checking Syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Error Reporting and Debugging Scripts . . . . . . . . . . . . . . . . . . . . . . . . . . Saving Scripts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Printing. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Page Setup. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Printing Scripts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Using the Tables and Columns Pick List . . . . . . . . . . . . . . . . . . . . . . . . . . Using the Views and Columns Pick List . . . . . . . . . . . . . . . . . . . . . . . . . . Using the Stored Procedures Pick List. . . . . . . . . . . . . . . . . . . . . . . . . . . . Using the T-SQL Syntax Pick List. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Using the System Procedures Syntax Pick List. . . . . . . . . . . . . . . . . . . . . Constructing Joins . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Recalling a Previous Query . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Using Result Windows . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Opening Result Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Editing Result Windows in Text Output Mode . . . . . . . . . . . . . . . . . . . . Editing Result Windows in Grid Output Mode . . . . . . . . . . . . . . . . . . . . Navigating Grid Output Result Windows . . . . . . . . . . . . . . . . . . . . . Selecting Cells. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Editing Cell Contents. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Copying Cell Contents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Selecting Rows . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Resizing Rows . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Copying Rows . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Selecting Columns . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Resizing Columns . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Copying Columns . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Finding Text in Grid Output Result window. . . . . . . . . . . . . . . . . . . Printing Results. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Saving Results . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Exporting Data to Other Products . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

2-28 2-29 2-31 2-31 2-32 2-32 2-33 2-33 2-35 2-36 2-38 2-39 2-40 2-42 2-43 2-44 2-46 2-46 2-47 2-47 2-48 2-48 2-48 2-49 2-49 2-50 2-50 2-50 2-51 2-51 2-52 2-52 2-52 2-53

SQL Advantage Users Guide

vii

SQL Advantage 11.0.x

Exiting SQL Advantage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-53

A. Command Line Parameters


Supported Command Line Parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Unsupported Command Line Parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Input/Output (I/O) Redirection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . A-1 A-4 A-4 A-5

B. Error Messages
Error Messages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . B-1

Index

viii

List of Figures
Figure 1-1: Figure 1-2: Figure 1-3: Figure 1-4: Figure 1-5: Figure 1-6: Figure 1-7: Figure 2-1: Figure 2-2: Figure 2-3: Figure 2-4: Figure 2-5: Figure 2-6: Figure 2-7: Figure 2-8: Figure 2-9: Figure 2-10: Figure 2-11: Figure 2-12: Figure 2-13: Figure 2-14: Figure 2-15: Figure 2-16: Figure 2-17: Figure 2-18: Figure 2-19: Figure 2-20: Figure 2-21: Figure 2-22: Figure 2-23: Figure 2-24: Figure 2-25: Figure 2-26: Figure 2-27: SQL Advantage Application and Session windows.................................................1-2 Toolbar...........................................................................................................................1-14 Session window status bar .........................................................................................1-18 Application window status bar .................................................................................1-18 Multiple text result window ......................................................................................1-20 Single text result window...........................................................................................1-21 Grid result window .....................................................................................................1-22 Starting from Windows NT 3.51 run dialog box .......................................................2-2 Preferences dialog box query preferences...............................................................2-5 Preferences dialog box connection preferences......................................................2-7 Preferences dialog box result preferences ...............................................................2-8 Preferences dialog box miscellaneous preferences ..............................................2-10 Connect dialog box......................................................................................................2-12 Connect Options dialog box.......................................................................................2-13 Session window ...........................................................................................................2-16 Open dialog box...........................................................................................................2-18 Load dialog box ...........................................................................................................2-20 Find dialog box ............................................................................................................2-24 Replace dialog box.......................................................................................................2-25 Font dialog box ............................................................................................................2-26 Sample batch script .....................................................................................................2-28 Selected script text .......................................................................................................2-29 Execute Stored Procedure dialog box .......................................................................2-30 Save As dialog box ......................................................................................................2-32 Page Setup dialog box.................................................................................................2-34 Print dialog box............................................................................................................2-35 Tables and Columns pick list .....................................................................................2-37 Views and Columns pick list......................................................................................2-38 Stored Procedures pick list .........................................................................................2-40 T-SQL Syntax pick list .................................................................................................2-41 System Procedures Syntax pick list...........................................................................2-42 Join Selection dialog box.............................................................................................2-43 History dialog box .......................................................................................................2-45 Edit Cell dialog box .....................................................................................................2-49

SQL Advantage Users Guide

ix

SQL Advantage 11.0.x

About This Book


Audience
This SQL Advantage Users Guide gives detailed procedures for starting, stopping, and using SQL Advantage. It is designed for Sybase SQL Server administrators, system architects, application developers, and users performing ad hoc queries on databases, all of whom may have varying levels of familiarity with Transact-SQL and SQL Server.

How to Use This Book


This SQL Advantage Users Guide includes the following: Chapter 1, Introduction, which gives an overview of SQL Advantage. Chapter 2, Using SQL Advantage, which describes how to start and stop SQL Advantage and gives detailed procedures for using SQL Advantage. Appendix A, Command Line Parameters, which provides brief descriptions of SQL Advantage command line parameters. Appendix B, Error Messages, which describes signicant SQL Advantage error messages, and what to do when you encounter them.

Related Documents
Other manuals that you may nd useful are: Transact-SQL Users Guide, which is a complete guide to TransactSQL. Open Client/Server Supplement, which contains detailed information on all isql command line parameters. SQL Server Reference Manual, which contains detailed information on all of the commands and system procedures discussed in this manual. System Administration Guide, which contains in-depth information about SQL Server administration issues.

SQL Advantage Users Guide

xi

Other Sources of Information

SQL Advantage 11.0.x

Microsoft Windows Users and Reference Guides.

Other Sources of Information


Sybase offers system and database administration classes called Fast Track to SQL Server, SQL Server Administration, and Advanced SQL Server Administration. For details, contact: Mail: Education Registrars Sybase Professional Services 77 South Bedford Street Burlington, MA 01803 Phone: (800) 8-SYBASE or (617) 564-6970 Fax: (800) 792-2733 or (617) 564-6960 Email: [email protected]

Conventions
Style Conventions
In this users guide, the following typefaces and fonts have special signicance:
Table 1: Style conventions Example
parameter sql.ini ssm

Used For
Command keywords, terms that are being dened, and emphasized text Filenames, variable names, and book titles Values that you type exactly as shown

Privileges
Some activities in SQL Advantage are restricted to users with specic Sybase roles or assignments, such as System Administrator (sa) or Database Owner (dbo). Some activities, such as using syntax pick lists, are dependent upon the type of SQL Server to which you are connected. When an activity has such a restriction, it is clearly indicated at the beginning of the activity. xii About This Book

SQL Advantage 11.0.x

If You Need Help

Mouse Buttons
Although not absolutely necessary, a pointing device such as a mouse makes SQL Advantage much easier to use. This users guide refers to mouse buttons as the left and right buttons, assuming the mouse has two buttons and is congured for right-hand use. On a mouse congured for left-hand use, the positions are reversed.

Screen Images
SQL Advantage runs on Windows NT 3.51, and Windows 95. In each environment, windows and dialog boxes have a somewhat different look, although their contents are identical. For consistency, this guide displays screen images of SQL Advantage running on a single platform, Windows NT 3.51.

If You Need Help


You can get help for using SQL Advantage from the printed documentation, online help, or your Technical Support Center.

SQL Advantage Users Guide

xiii

If You Need Help

SQL Advantage 11.0.x

xiv

About This Book

1
Overview

Introduction

1.

SQL Advantage is an easy-to-use Transact-SQL (T-SQL) editor that helps you compose syntactically correct T-SQL command statements with the assistance of T-SQL command templates and point-andclick tools. You can then execute your T-SQL queries, and view the results either as text, or within a gridded, spreadsheet-like display. SQL Advantage can save results data in common PC le formats that can then be imported into other applications (for example, Microsoft Excel).

SQL Advantage Session Windows


SQL Advantage may have zero, one, or more documents open at any given time, each having its own session window. Each new session window (see Figure 1-1 on page 1-2) has a query window pane, where you enter your query scripts; and an associated message window pane, located below the query window pane. The message window pane displays query execution errors and informational messages. The message window pane is hidden if the splitter bar is pulled all the way down, and the query pane is hidden if the splitter bar is pulled all the way up. Each session window may or may not have connection to a SQL Server. You can start editing a script in the query window pane without having a connection to a SQL Server. You can create and execute T-SQL queries (scripts) from the query window pane. After you execute your queries, results are displayed in separate result windows (see SQL Advantage Result Windows on page 1-18).
Note Fatal communication errors and unexpected internal errors are displayed in alerts, not in the message window pane.

SQL Advantage Users Guide

1-1

SQL Advantage Session Windows

SQL Advantage 11.0.x

Figure 1-1: SQL Advantage Application and Session windows

SQL Advantage has the following application and session window indicators and controls: Application control menu Application window minimize/maximize controls Application window status bar Application window main menu bar Application window toolbar Session window control menu Session window minimize/maximize controls Session window status bar

1-2

Introduction

SQL Advantage 11.0.x

SQL Advantage Session Windows

About Menus
Note that menus in the SQL Advantage menu bar have one letter underlined; this is a mnemonic key that you can use, in combination with the Alt key, to select that menu should you not have a mouse. For example: Application Window control menu, select Alt + Space Session Window control menu, select Alt + Result Window control menu, select Alt + File menu, select Alt + F Edit menu, select Alt + E View menu, select Alt + V Server menu, select Alt + S Query menu, select Alt + Q Window menu, select Alt + W Help menu, select Alt + H Similarly, most menu commands have one letter underlined that you can use to invoke that command after the menu has been selected. Also, some menu commands have short-cut accelerator keys that you can use to invoke the command. Where applicable, these short cut accelerator keys appear to the right of the command in the menu.

Application Window Control Menu


The application window control menu is a drop-down menu displayed when you click the mouse button in the close box in the top left corner of the SQL Advantage application window (see Figure 1-1 on page 1-2). The application control menu has the following commands: Restore Restores the application window to its previous size after it is minimized or maximized. Move Lets you use the keyboard to move the application window to another position. Size Lets you use the keyboard to change the size of the application window.

SQL Advantage Users Guide

1-3

SQL Advantage Session Windows

SQL Advantage 11.0.x

Minimize Reduces the application window to an icon on the desktop. Maximize Enlarges the application window to its maximum size. Close Closes your Windows session and dismisses the SQL Advantage application window. Switch To... Opens a task list that you can use to switch between running applications and rearrange their windows and icons.

Main Menu Bar


Reading from left to right across the menu bar (see Figure 1-1 on page 1-2), SQL Advantage has the following menus: File Edit View Server Query Window Help File Menu The File menu has the following commands: New Opens a new session window to edit scripts. The new session window inherits global preferences (see Setting Preferences on page 2-3 ).
Note Opening a new session window does not automatically establish a SQL Server connection.

Open... Opens an existing SQL Advantage query script, or saved results, from a saved le, into a new window. SQL Advantage remembers the last selected type of le in the current application.

1-4

Introduction

SQL Advantage 11.0.x

SQL Advantage Session Windows

Up to four of the most-recently, worked-on les are listed at the bottom of the File menu. You can quickly reopen any of these les by clicking the le name. You can also quickly open any of your saved SQL Advantage les by double-clicking the appropriate lename in the File Manager.
Note To open a saved SQL Advantage le by double-clicking a lename in File Manager, you must establish an appropriate association for each type of SQL Advantage le (*.sql, *.txt, and *.rpt).

Load... Loads a query script into an active session window using the Load dialog box. A new script is inserted at the current cursor location in the query window pane. If text is selected in the query window pane prior to loading a script, the new script replaces the current text selection. This command is disabled if no query window is open. Close Closes the active window. If there are any unsaved changes in the window, and you have set your preferences to do so, an optional closing message dialog box opens prompting you to save the changes rst. Closing a session window disconnects the connection to SQL Server, if any. If a query session is in progress, you are prompted to cancel that query before closing. When closing a result window, if you set your preferences to do so, you are prompted to save rst. You can also close a window using the windows control menu. If SQL Advantage has no query sessions or result windows open, this command is disabled. Save For query windows, saves the current query script (with its messages) to a specied lename. Preferences, font information, and any messages are saved with session les. You can save the le as: - A session le which contains the query script and all associated messages and preferences. The default extension is .sql. - A text le which contains just the query script. The default extension is .txt.

SQL Advantage Users Guide

1-5

SQL Advantage Session Windows

SQL Advantage 11.0.x

For result windows, saves the contents and font to a specied lename. You can save the le as: - A text le which contains just the result data for a single text result window. The default extension is .txt. - For grid result windows, a result le which contains the result data and grid layout information. The default extension is .rpt. - For multiple text result windows, a result le which contains the result data information. The default extension is .rpt. If the specied <lename> already exists, a prompt asks you if you want to overwrite it. A saved grid result window is reopened as a grid window. Its formatted options are saved with the result le. The rst time you save a window to a le, the Save As dialog box opens to prompt you to specify the le name; thereafter, the le is saved immediately with no dialog prompt. To save an existing script or set of results under another name, choose Save As... from the File menu. If SQL Advantage has no query or result windows open, or if no changes have been made since the window was last saved, the Save command is disabled. Save As... Saves the contents of the current active window and the font to a new renamed le without changing the existing le using the standard Windows Save As dialog box. For query windows, you can save the le as: - A session le which contains the query script and all associated messages and preferences. The default extension is .sql. - A text le which contains just the query script. The default extension is .txt. For result windows, you can save the le as: - For a single text result window, a text le which contains just the result data . The default extension is .txt. - For a single text result window, a result le which contains just the result data. The default extension is .rpt - For grid result windows, a result le which contains the result data and grid layout information. The default extension is .rpt. - For multiple text result windows, a result le which contains the result data information. The default extension is .rpt.

1-6

Introduction

SQL Advantage 11.0.x

SQL Advantage Session Windows

If the specied <lename> already exists, a prompt asks you if you want to overwrite it. In the Save As dialog box, select the le type from the Save File As Type drop-down list. Note that this list is dependent upon the type of window that is currently active. If SQL Advantage has no query or result windows open, the Save As... command is disabled. Save All Saves all the open, changed query and result windows to separate les. You are prompted for a different le name for each window if it has not been previously saved. If SQL Advantage has no query sessions or result windows open, this command is disabled. Preferences Lets you set user preferences for SQL Advantage. When you choose Preferences from the File menu, you must then choose either global or session preferences from a cascading menu that opens to the right of the Preferences command. Session preferences apply only to the current session; global preferences, if changed, do not apply to the current session, but do apply to all newly created sessions. Set your session or global preferences in each of the following four categories: - Query preferences for the query session window and query execution - Connection preferences for SQL Server connection - Result preferences fortype of result window and display of query results - Miscellaneous miscellaneous application preferences Session preferences are disabled if the window having focus is not a session window. Print... Controls how the contents of a query window pane, message window pane or result window are printed. The contents of the window having current focus are printed out. Before using this command, you must install and select a printer. To install and select a printer, see your Microsoft Windows documentation. You can print: - The complete document; that is, all the pages comprising a multipage document

SQL Advantage Users Guide

1-7

SQL Advantage Session Windows

SQL Advantage 11.0.x

- A range of pages in the document; that is, a subset of the document - Only specic text selected in the query pane of the session window or the result pane of the result window. Text in the query pane of a text result window is not printed.
Note For a result window in grid output mode, you can print only the complete contents of a single cell (that is, partial contents of a cell are not allowed) or the complete contents of a contiguous group of cells, rows, or columns.

Page Setup... Lets you set page headers and footers, page margins, and the order in which pages are printed. Exit Closes all open windows prompting you to save any unsaved data, performs the necessary clean-up before exiting from the application, and shuts down from SQL Server. Edit Menu The Edit menu has the following commands: Undo Undoes the last edit operation on the current editable window only. If the last edit operation cannot be undone, this command is disabled. Where applicable, you can undo the Undo command (that is, redo). Cut Removes selected text in the current window and puts it on the Clipboard. Text that you place on the Clipboard replaces the previous contents of the Clipboard. This command is available only after you select text. Copy Copies selected text in the current window to the Clipboard. Text that you copy to the Clipboard replaces the previous contents of the Clipboard. Text may be copied from anywhere it can be selected. Paste Inserts a copy of the Clipboard textual contents at the insertion point, in any text window, replacing the selection in the current window (if any) with the text on the Clipboard. This command is disabled if the Clipboard is empty, or does not contain text, or if the current window having focus is a grid window or the message pane of the session window.

1-8

Introduction

SQL Advantage 11.0.x

SQL Advantage Session Windows

Clear/Clear All Messages In the query window pane, the Clear command removes selected text in the current window. Note that this command does not copy selected text to the Clipboard. If you click or select text in the message window pane, this command changes to the Clear All Messages command which removes all messages displayed in the message window pane. Select All Selects all text in the current query window pane, message window pane, or result window in text output mode; or all the rows/columns/cells in a result window in grid output mode. Find... Lets you search for specic text sequences within the current query, message, or result window. Replace... Lets you search for a specic text sequence within the current query, message, or result window in text output mode, and replace it with another specied text sequence. This function is disabled for session windowmessage panes and grid result windows . Font... Lets you change the font in the current window. Font changes apply to the entire window. The Font command is disabled for grid result windows. View Menu The View menu has the following commands: Tool bar Toggles the toolbar display on and off. When the toolbar is displayed, a check mark appears beside this command. Status bar If a session window has focus, toggles the session window status bar display on and off, but not the application window status bar. When the session window loses focus, this command toggles the application window status bar display on and off. When the status bar is displayed, a check mark appears beside this command. Edit Cell... Enabled only when you select a single cell in a grid result window; it is disabled if you attempt to select multiple cells. When results are displayed in grid output mode, results data for columns is displayed up to the display text length option specied in your Result Preferences. When you choose the Edit Cell... command, the Edit Cell dialog box opens to let you edit the full contents of the selected cell. You must click OK to accept your editing changes, or cancel the edit

SQL Advantage Users Guide

1-9

SQL Advantage Session Windows

SQL Advantage 11.0.x

cell operation before you can perform any other work. Edited results cell content is for your information purposes only; it does not alter data in the database. Refresh Lists Refreshes the contents of the database drop-down list box on the toolbar, and the Tables and Columns, Views and Columns, and Stored Procedures pick lists. This command is enabled only when a query session is open and you are connected to a SQL Server. Pick Lists To enhance accuracy and increase productivity, oating, modeless pick lists let you easily insert column, table, view, and stored procedure names, and T-SQL commands and system procedures syntax into query windows. You can also use the stored procedures pick list to select and execute procedures. The pick lists are sensitive to the current session windows database connection and the Tables and Columns, Views and Columns, and Stored Procedures pick lists update themselves when the connection changes. The pick list subcommands are enabled only when a query window is open and has focus, and you are connected to a SQL Server. Pick lists are not enabled when a result window has focus, if the session window is minimized, or if there is no connection to SQL Server. - Tables & Columns Invokes the Tables and Columns pick list. Each primary level in this hierarchal pick list represents a table with its columns indented beneath it. The tables are listed in alphabetical order by name, and the owner name follows the table name, in parentheses, if the owner is not dbo. - Views & Columns Invokes the Views and Columns pick list. Each primary level in this hierarchal pick list represents a view with its columns indented beneath it. The views are listed in alphabetical order by name, and the owner name follows the view name, in parentheses, if the owner is not dbo. - Procedures Invokes the Stored Procedures pick list. The stored procedures are listed in alphabetical order and include the system stored procedures. The owner name follows the stored procedure name, in parentheses, if the owner is not dbo. - T-SQL Commands Syntax Invokes the T-SQL Commands Syntax pick list. The T-SQL commands are listed in alphabetical order. - System Procedures Syntax Invokes the System Procedures Syntax pick list. The system procedures are listed in alphabetical order.

1-10

Introduction

SQL Advantage 11.0.x

SQL Advantage Session Windows

Note T-SQL Commands Syntax and System Procedures Syntax pick lists are disabled if not connected to SQL Server release 10.0 or later, or if the sp_syntax stored procedure is not fully installed on the SQL Server to which you are connected.

Server Menu The Server menu has the following commands: Connect... Lets you connect a session to a SQL Server by opening a connect dialog box. You may have multiple connections to one or more servers, but each connection is maintained within a different session window. If you choose Connect while connected to a SQL Server, you are prompted to disconnect from the current SQL Server before connecting to a different SQL Server, or the same one again. Disconnect Enables dropping of the connection from a SQL Server in the active session window. A message box opens prompting you to conrm this intent. After disconnection, note that the session window remains open and any text in the query pane remains visible.
Note Before disconnecting, you must cancel any executing queries.

Query Menu The Query menu has the following commands: Execute Query/Execute Selection If you have a highlighted selection in the query window pane, the Execute Query command changes to the Execute Selection command. This command executes the script in the query window pane. SQL Advantage submits the script to SQL Server for execution. The current SQL Advantage session then waits for SQL Server to process the script. If there is no connection to SQL Server, you are prompted to connect before execution can happen. This command is disabled if:

SQL Advantage Users Guide

1-11

SQL Advantage Session Windows

SQL Advantage 11.0.x

- There is no text in the session window query pane - The window with focus is not a session window - A query is executing for the current query window - The session window is minimized Cancel Execution Cancels execution of a current query in progress. This command is enabled when there is an active query executing in the session window having focus, or when a result window is being lled (in which case, it cancels result display). History... Lets you access the query script history by opening the History dialog box. This dialog box lists the last ten recorded scripts for the active query session. The rst item in the list (the most-recently recorded) is initially selected. This command is disabled if a session window does not have focus or if there is no connection to a SQL Server. Execute Stored Procedure... Opens the Execute Stored Procedure dialog box for you to execute a stored procedure. A drop-down list box is populated with stored procedures taken from the currently used database, from sybsystemprocs (the system stored procedures) if you are running SQL Server release 10.0 and later; and from the master database if you are running SQL Server pre-release 10.0. At the rst invocation of this dialog, nothing is selected in the drop-down list box; otherwise, it remembers the last-selected stored procedure. This command is enabled only when a session window has focus, and you are connected to a SQL Server. Disabled if a query is executing in the session window. Joins... To assist you in constructing joins, this command opens the Join Selection dialog box that displays column join candidates for any two selected tables or views (similar to the output from the system stored procedure, sp_helpjoins). You can paste this join query segment into the current query window. This command is enabled only when a session window has focus, and you are connected to SQL Server. Disabled if a query is executing in the session window. Window Menu The Window menu has the following commands: Cascade Arranges the open group windows in an overlapping pattern so that the title bar of each window is visible.

1-12

Introduction

SQL Advantage 11.0.x

SQL Advantage Session Windows

Tile Arranges the open group windows in a tile pattern where each window is of equal size and all the tiled windows ll the monitor screen. Open Windows List A horizontal line below the Windows menu commands divides the Window menu into two distinct areas. The area below the line lists open SQL Advantage windows. A check mark appears beside the window having current focus. To change focus to another window, choose the appropriate window name in the list. Help Menu The Help menu has the following commands: Contents Displays the contents of the online help, reference information, and step-by-step instructions for using SQL Advantage. Search for Help on... Lets you search in SQL Advantage online help for information related to specic topics. After choosing the Search for Help on... command, type the topic name or select it from the list in the Search dialog list box, and then click the Show Topics command button to see related topics. To display a particular topic from the list of topics, select it and then click Go To. To quickly search for information in the online help system, open the Search dialog box. How to Use Help Instructions on how to use online help. In the Help window, use the scroll bar to view information not visible. Technical Support Contact information for Sybase Technical Support. About SQL Advantage... SQL Advantage release and copyright information.

Toolbar
SQL Advantage has a toolbar that provides quick access to some SQL Advantage menu commands (see Figure 1-2 on page 1-14 and Table 1-1 on page 1-14). Toggle the toolbar display on and off by choosing Tool bar from the View menu. When the toolbar is displayed, a check mark appears beside this command. SQL Advantage Users Guide 1-13

SQL Advantage Session Windows

SQL Advantage 11.0.x

Note the SQL Advantage toolbar follows standard Windows behavior as described in the Microsoft Windows Users Guide.

Figure 1-2: Toolbar

Toolbar Microhelp When you position the mouse cursor over a toolbar command button, and wait 2 seconds or more before you click a mouse button, a one- or two-word message describing that command is displayed in a tooltip over the command button. An expanded microhelp description is also displayed in the application window status bar (see Figure 1-4 on page 1-18):
Table 1-1: Toolbar Commands Command
New Open Save Print

Description
Same as the New command in the File menu Same as the Open command in the File menu Same as the Save command in the File menu Same as the Print command in the File menu

For more information...


See File Menu on page 1-4 See File Menu on page 1-4 See File Menu on page 1-4 See File Menu on page 1-4

1-14

Introduction

SQL Advantage 11.0.x

SQL Advantage Session Windows

Table 1-1: Toolbar Commands (continued) Command


Preferences

Description
Same as the Preferences command in the File menu. If a session window has focus when you invoke this command, you can set preferences just for the current session. If a session window does not have focus when you invoke this command, you can set global preferences which are retained between sessions. Same as the Undo command in the Edit menu Same as the Cut command in the Edit menu Same as the Copy command in the Edit menu Same as the Paste command in the Edit menu Same as the Find command in the Edit menu Same as the Execute command in the Query menu Same as the Cancel Execution command in the Query menu Lists all the available databases from the current sessions connected SQL Server. To quickly change from one database to another within a connected session to SQL Server, select the appropriate database name from the dropdown list box.

For more information...


See File Menu on page 1-4

Undo Cut Copy Paste Find Execute Cancel Execution Change Database

See Edit Menu on page 1-8 See Edit Menu on page 1-8 See Edit Menu on page 1-8 See Edit Menu on page 1-8 See Edit Menu on page 1-8 See Query Menu on page 1-11 See Query Menu on page 1-11 See Changing Database on page 2-21. Note that changing database changes the context of the rst three pick lists in the View menu. For more information, see Using the Tables and Columns Pick List on page 2-36, Using the Views and Columns Pick List on page 2-38, and Using the Stored Procedures Pick List on page 2-39.

SQL Advantage Users Guide

1-15

SQL Advantage Session Windows

SQL Advantage 11.0.x

Application Window Minimize Control


The application window Minimize command button (see Figure 1-1 on page 1-2) reduces the SQL Advantage application window to an icon on the desktop. This command button performs the same function as the Minimize command in the application control menu.

Application Window Maximize Control


The application window Maximize command button (see Figure 1-1 on page 1-2) enlarges the SQL Advantage application window to full screen size. This command button performs the same function as the Maximize command in the application control menu.

Application Window Restore Control


When the application window is maximized, the Maximize command button (see Figure 1-1 on page 1-2) changes to the Restore command button. Clicking the Restore command button restores the SQL Advantage application window to its previous screen size. This command button performs the same function as the Restore command in the application control menu.

Session Window Control Menu


The session window control menu is a drop-down menu displayed when you click the mouse button in the close box in the upper left corner of the SQL Advantage session window (see Figure 1-1 on page 1-2). The session control menu has the following commands: Restore Restores the session window to its previous size after it has been minimized or maximized. Move Lets you use the keyboard to move the session window to another position. Size Lets you use the keyboard to change the size of the session window. Minimize Reduces the session window to an icon in the application. Maximize Enlarges the session window to its maximum size.

1-16

Introduction

SQL Advantage 11.0.x

SQL Advantage Session Windows

Close Dismisses the SQL Advantage session window. Next Takes you to the next SQL Advantage document in the open Windows list if you have more than one SQL Advantage document open (see Window Menu on page 1-12). If you have only one document open, it does nothing.

Session Window Minimize Control


The session window Minimize command button (see Figure 1-1 on page 1-2) reduces the SQL Advantage session window to an icon within the application window. This command button performs the same function as the Minimize command in the session control menu.

Session Window Maximize Control


The session window Maximize command button (see Figure 1-1 on page 1-2) enlarges the SQL Advantage session window to full size within the application window. This command button performs the same function as the Maximize command in the session control menu.

Session Window Restore Control


When the session window is maximized, the Maximize command button (see Figure 1-1 on page 1-2) changes to the Restore command button. Clicking the Restore command button restores the SQL Advantage session window to its previous screen size. This command button performs the same function as the Restore command in the session control menu.

Session Window Status Bar


The session window status bar (see Figure 1-3 on page 1-18) located at the bottom of the session window (see Figure 1-1 on page 1-2) displays the following current session status: Session status SQL Server name Login name

SQL Advantage Users Guide

1-17

SQL Advantage Session Windows

SQL Advantage 11.0.x

Current database the login is connected to, if any Result window display mode

Figure 1-3: Session window status bar

When the display mode for the result window is Grid, SQL Advantage displays the word Grid on the status bar. When the display mode is set to Text output, SQL Advantage displays the word Text. If SQL Advantage is started from the command line with the -o option, it displays File:<lename>.

Application Window Status Bar


The application window status bar (see Figure 1-4 on page 1-18) at the bottom of the SQL Advantage application window displays toolbar and menu command microhelp messages and keyboard lock key status. To toggle the display of this status bar on and off, choose Status bar from the View menu. This is only if there are no session windows open, or if a result window has focus, otherwise, it toggles the session window status bar. When the status bar is displayed, a check mark appears beside this command.

Figure 1-4: Application window status bar

1-18

Introduction

SQL Advantage 11.0.x

SQL Advantage Result Windows

SQL Advantage Result Windows


Result windows open following the successful execution of a query. Result window contents are displayed as text or in a spreadsheet-like grid according to preferences that you set (see Setting Result Preferences on page 2-7). The default result window display is single text. You can edit results data using standard Windows editing functions such as cut, copy, and paste.
Note You can edit only the results data, not the actual data in the database. You cannot update the database by editing the results.

Result Window Controls


Result windows have a control menu, and Minimize and Maximize controls that are similar to the corresponding session window controls (see Session Window Control Menu on page 1-16, Session Window Minimize Control on page 1-17, and Session Window Maximize Control on page 1-17).

Text Output Mode


According to preferences that you set, when you choose to display results in text output mode, you can also choose to create a single text result window for all query batches, or create multiple windows with a separate result window for each batch (see Setting Result Preferences on page 2-7). The contents of a single text result window are overwritten by the results of subsequent executions of query scripts in the associated query window. When you select multiple text result windows, the results for each query appear in a separate result window. Multiple Text Result Windows When you display results in multiple text result windows (see Figure 1-5 on page 1-20), a result window opens for each query within the script, displayed in a cascaded fashion.

SQL Advantage Users Guide

1-19

SQL Advantage Result Windows

SQL Advantage 11.0.x

Each multiple result window comprises two panes. The upper query window pane displays the corresponding T-SQL query within the script, and the lower result window pane contains the results of the execution of that query. The query script in the result window query pane cannot be selected for execution; however, you can select the text, copy it to the session window query pane, and execute it from there.

Figure 1-5: Multiple text result window

Single Text Result Window When you choose to display results in single text result windows (see Figure 1-6 on page 1-21), a single result window displays all the results after you execute a query that returns one or more sets of results, regardless of the size of the script. In a single text result window, results are displayed with the same output format as that used by Sybase ISQL. Each single text result window has only one window pane that displays all the results from your query. There is no result window message pane as in multiple text result windows.

1-20

Introduction

SQL Advantage 11.0.x

SQL Advantage Result Windows

Figure 1-6: Single text result window

Grid Output Mode


When results are displayed in grid output mode, a separate grid result window opens for each query within the script, just as with multiple text result windows. A grid result window is created for every query execution (see Figure 1-7 on page 1-22). The upper, query window pane contains the corresponding T-SQL query within the script, and the lower, result window pane contains the result of that query execution. Text up to the length specied by the text display length option in the Result Preferences dialog box can be displayed. Maximum text buffer size is specied by the Text/Image Size preference (see Setting Result Preferences on page 2-7). If you click a cell and then choose Edit Cell... from the View menu, or double-click a cell, the Edit Cell dialog box opens (see Figure 2-27 on page 2-49) which, in the case of text or image data type, displays all text up to the size of the Text/Image Size buffer. For other cells, the entire contents are displayed. You can perform standard editing functions on the results text in the cell using this dialog box. The edited cell content does not alter data in the database, that is you cannot update the database by editing the results.

SQL Advantage Users Guide

1-21

SQL Advantage Result Windows

SQL Advantage 11.0.x

Figure 1-7: Grid result window

1-22

Introduction

2
Introduction

Using SQL Advantage

2.

This chapter gives you detailed instructions on performing the following tasks: Starting SQL Advantage 2-1 Setting Preferences 2-3 Connecting to SQL Server 2-11 Using Session Windows 2-16 Using Query Construction Tools 2-36 Using Result Windows 2-46 Exiting SQL Advantage 2-53

Starting SQL Advantage


Starting SQL Advantage on Windows NT 3.51
Common ways to start SQL Advantage on this platform are as follows. Starting from Icon In the Program Manager, double-click the SQL Advantage icon. Starting from Command Line 1. In either the Program Manager or File Manager, choose Run... from the File menu; the Run dialog box opens (see Figure 2-1 on page 2-2). 2. In the Command Line text box, enter the command line or append the command line parameters to the executable command line that is already in the text box, and click OK (see Appendix A, Command Line Parameters.)

SQL Advantage Users Guide

2-1

Starting SQL Advantage

SQL Advantage 11.0.x

Note For the default installation, the executable command line is: Local Drive:\sybase\sqladv.exe

3. The SQL Advantage application window opens as described in SQL Advantage Session Windows on page 1-1. Other standard ways to launch applications on Windows NT 3.51 are described in the Microsoft Windows NT Users Guide.

Figure 2-1: Starting from Windows NT 3.51 run dialog box

Starting SQL Advantage on Windows 95


Common ways to start SQL Advantage on this platform are as follows. Starting from Start Menu Click Start, then choose Programs from the cascading menu that appears, and then choose SQL Advantage from the next cascading menu. The SQL Advantage application window opens as described in SQL Advantage Session Windows on page 1-1. Starting from Icon From the Explorer, double-click the SQL Advantage icon; the SQL Advantage application window opens as described in SQL Advantage Session Windows on page 1-1.

2-2

Using SQL Advantage

SQL Advantage 11.0.x

Setting Preferences

Starting from Command Line 1. Click Start, then choose Run; the Run dialog box opens (similar to Figure 2-1 on page 2-2). 2. In the Command Line text box, enter the command line or append the command line parameters to the executable command line that is already in the text box, and click OK (see Appendix A, Command Line Parameters.).
Note For the default installation, the executable command line is: Local Drive:\sybase\sqladv.exe

3. The SQL Advantage application window opens as described in SQL Advantage Session Windows on page 1-1. Other standard ways to launch applications on Windows 95 are described in the Microsoft Windows 95 Users Guide.

Setting Preferences
To set SQL Advantage preferences, choose Preferences from the File menu, or select the Preferences command button on the toolbar. When you use the File menu, you can choose either Session or Global preferences from a cascading menu. Session preferences apply only to the current session; global preferences are retained between sessions. If changed, global preferences do not apply to the current session, but do apply to all newly created sessions. If a session window has focus when you use the Preferences command button on the toolbar, you can set session preferences. If a session window does not have focus when you invoke this command, you can set global preferences. Global preferences are retained between invocations of SQL Advantage in a le called sqladv.ini which is located in the Windows directory on your local drive. To reset global preferences to the factory settings, delete the sqladv.ini le before launching SQL Advantage; a new sqladv.ini le is created when you relaunch. When you invoke the Preferences command by either method, the Preferences dialog box opens. The Preferences dialog box has four tabbed property pages. The rst time this dialog box opens during the current invocation of the application, the Query preferences

SQL Advantage Users Guide

2-3

Setting Preferences

SQL Advantage 11.0.x

property page has focus, otherwise, the last property page used during the current session has focus. The Preferences dialog box is identical for both session and global preferences with two exceptions: The session preferences dialog box has an extra button (Default) that you can use to reset the current session preferences to the default values specied for your global preferences. The Error Log File preferences in the Miscellaneous Preferences property page apply only to global preferences. You can set your global or session preferences, in each of the following four categories, by clicking the corresponding tab. Query Preferences Connection Preferences Result Preferences Miscellaneous Preferences The Default command button appears only after you choose Session preferences. To apply global default preference values for subsequent sessions, click Default, then click Apply or OK. At any time, click Cancel to dismiss the Preferences dialog box without accepting any changes made; click Apply to save all changes made in all the preferences property pages without dismissing the preferences dialog box; and click OK to accept all changes made and dismiss the Preferences dialog box. This includes changes to the preferences property page having current focus, and the other three preferences property pages not having focus.

Setting Query Preferences


Figure 2-2 on page 2-5 illustrates the Query property page in the Preferences dialog box.
Note No Execute and Parse Query Only are mutually exclusive; if one is selected, the other is automatically disabled.

2-4

Using SQL Advantage

SQL Advantage 11.0.x

Setting Preferences

Figure 2-2: Preferences dialog box query preferences

Set Query Preference options as follows: To make the SQL Server optimizer process joins in the same order as the tables appear in the FROM clause, select the Force Query Plan check box. It essentially overrides the optimizer. To make SQL Server check only the syntax of each query script and return any error messages without compiling and executing the query, select the Parse Query Only check box. The output is always displayed in the message pane. To make SQL Server compile the query script without executing it, select the No Execute (compile only) check box. To automatically record each script executed, select the Automatic History Recording check box. If you do not select this check box, the recording mode is manual where you may selectively choose which scripts to record. If you select Automatic History Recording mode, you can still record a script manually. The default is Automatic History Recording selected. To generate a text description of the processing plan for the query as the query is processed, select the Query Process Plan check box. The output is always displayed in the message pane. To display the time it takes to parse and compile each query statement, and the time it takes to execute each step of the query

SQL Advantage Users Guide

2-5

Setting Preferences

SQL Advantage 11.0.x

statement, select the Query Time Statistics check box. The output is always displayed in the message pane. To display the number of scans, logical reads, and physical reads for each table referenced in the query statement, select the Query I/O Statistics check box. The output is always displayed in the message pane. Type the terminating string to place between individual queries in a batch in the Code Terminator text box. The terminator string must adhere to the following rules: - Be no more than 5 characters in length - First character must be a letter of the alphabet - Cannot include embedded spaces - Cannot include semicolon (;) - Cannot include arithmetic or binary operators - Must be case-insensitive - Cannot be one of the reserved T-SQL keywords The default is GO. Specify the time, in seconds, that SQL Advantage waits for a SQL Server response to a query in the Query Timeout text box. The default is 60 seconds.

Setting Connection Preferences


Figure 2-3 illustrates the Connection property page in the Preferences dialog box. Set Connection Preference options as follows: Select the default SQL Server to use in the Connect dialog from the Server Name drop-down list box. The drop-down list box lists all the SQL Server names taken from the registry or interfaces le in the $SYBASE/ini directory or as specied in the -I command line parameter. If no interface le is found, the drop-down list box is empty. It is initialized to the server supplied on the command line. If none is provided, it defaults to the value of $DSQUERY, and if this is not dened, it defaults to SYBASE, if it exists.

2-6

Using SQL Advantage

SQL Advantage 11.0.x

Setting Preferences

Figure 2-3: Preferences dialog box connection preferences

Specify your login name on the selected SQL Server in the Login Name text box. For new sessions, your login name in the Connect dialog box (see Figure 2-6) defaults to whatever you specify for this preference when setting global connection preferences; otherwise, it defaults to your current session login name preference. Specify the default client host name to use in the Client Host Name text box. The client host name is initialized to the name supplied on the command line by the H parameter (see Appendix A, Command Line Parameters.) If this is not specied, the machine name is the default. The client host name is restricted to 10 characters. Specify the length of time, in seconds, in the Login timeout text box that SQL Advantage waits for a SQL Server response after making a login request.

Setting Result Preferences


Figure 2-4 illustrates the Result property page in the Preferences dialog box. Set Result Preference options as follows:

SQL Advantage Users Guide

2-7

Setting Preferences

SQL Advantage 11.0.x

To create one result window for all the batches, select the Result Windows Single Text option button. This is the default. To create a result window for every single batch, select the Result Windows Multiple Text option button.

Figure 2-4: Preferences dialog box result preferences

To display every separate batch result in its own window, select the Result Windows Grid option button. This is the default result window mode of operation. When Grid is selected, the following conditions apply: - Output Format is disabled - Display Column Heading is disabled - Display PRINT Messages With Results is disabled To run queries that exceed your system memory and also synchronize SQL Server messages with results, select the Row by Row Processing check box. When this check box is not selected, batch processing mode is specied. The default is Row by Row Processing not selected (that is, batch processing mode enabled). When working with large rows containing text or image data, specify row by row processing with a small batch size (see next bulleted item), and redirect the output to a le using the -o command line parameter (see Appendix A, Command Line Parameters.) 2-8 Using SQL Advantage

SQL Advantage 11.0.x

Setting Preferences

In the Batch Size text box, enter how many rows are to be processed before the result window is updated. The bigger the batch size, the faster the response; however, the window is not updated as often. The default batch size is 200 rows. In row by row processing mode only, batch size determines how many rows are stored in memory. When working with large rows containing text or image data, specify row by row processing with a small batch size, and redirect the output to a le using the -o command line parameter (see Appendix A, Command Line Parameters.) Specify the number of characters to be displayed in text or binary/image columns in the Display Length text box. The default is 255. In text output mode, text is clipped to the specied width. In grid out put mode, it species the initial width of the column although the column can be resized (see Resizing Columns on page 2-51). Specify the maximum size, in bytes, that SQL Server returns for a column of text or image datatype in the Text/Image Size text box. The limit is 2.147 gigabytes. To display a count of the number of rows affected by the SQL statement, select the Display Row Count Message check box. To display the column headings for each query result, select the Display Column Headings check box. This option is available only when results are displayed in Text mode. To display PRINT messages to the result window rather than the message pane, select the Display PRINT Messages With Results check box. This option is available only when results are displayed in Text mode. When displaying results in Text mode, select the delimiter to be used between column results from the Output Format dropdown list box. You can select: - Column Aligned (blank spaced lled) - Comma Separated Value (CSV) - Tab Delimited - User Dened (when this option is chosen, the Delimiter text box is enabled). The default is Column Aligned.

SQL Advantage Users Guide

2-9

Setting Preferences

SQL Advantage 11.0.x

When User Dened Delimiter output format is selected, specify delimiters to be used between column results in the Delimiter text box (5 characters maximum). - When Column Aligned output format is selected, text boxdisplays a space and is disabled. - When CSV output format is selected, text box displays only a comma (,) and is disabled. - When Tab Delimited output format is selected, text box displays tab and is disabled. To return all rows for a query, select the All Row Count option button for SQL Server. The default is All rows selected. To set a limit for the maximum number of rows SQL Server returns for a query, select the Maximum Row Count option button, and enter a value in the adjacent text box. The default is 32.

Setting Miscellaneous Preferences


Figure 2-5 illustrates the Miscellaneous property page in the Preferences dialog box.

Figure 2-5: Preferences dialog box miscellaneous preferences

2-10

Using SQL Advantage

SQL Advantage 11.0.x

Connecting to SQL Server

Set Miscellaneous Preference options as follows: To set word wrapping in the Query window pane, select the Word Wrap check box. This does not affect the Message window pane. The default is Word Wrap not selected. To prompt you to save a window that has been changed, select the Prompt on Unsaved Changes check box. The default is prompt on unsaved changes selected. To set font preferences, select the Font... command button; the Font dialog box opens (see Figure 2-13). The font preferences you select are for the current session only if you are setting session preferences; and are for all subsequent sessions if you are setting global preferences. To set the width of a tab character, type a value in the Tab Width check box. The default is 4. When setting Global preferences only, select the Log Error Messages to File check box to log every error message into a log le. If the le already exists, the contents of the le are replaced with the messages from the current application invocation. This check box is disabled when setting Session preferences. By default, this option is enabled for Global preferences. This is a global preference only; the Log File Name text box is disabled when setting Session preferences. Specify your usersupplied log le name in this text box. The default is sqlerror.log in the current working directory. Type an appropriate le name in the text box, or alternatively, use the Browse... command button to select a le using the Select Error Log File Dialog Box. If you change the name of your error log le, the old error log le is closed and a new one is opened.

Connecting to SQL Server


Before you can execute a query, you must establish a SQL Server connection. To do this, in the SQL Advantage session window, choose Connect... from the Server menu; the Connect dialog box opens (see Figure 2-6). If you choose Connect while connected to a SQL Server, you are prompted to disconnect from the current SQL Server before connecting to a different SQL Server, or to the same one again.

SQL Advantage Users Guide

2-11

Connecting to SQL Server

SQL Advantage 11.0.x

Figure 2-6: Connect dialog box

Connect to SQL Server as follows: 1. In the Server text box, specify the SQL Server to which you want to connect. Select a SQL Server name from the drop-down list box. The drop-down list box lists all the SQL Server names taken from the registry or interfaces le in the $SYBASE/ini directory or as specied in the I command line parameter (see Appendix A, Command Line Parameters.) If no interface le is found, the drop-down list box is empty.
Note Note this text box defaults to the Server Name from the Connection Preferences dialog box (see Setting Connection Preferences on page 2-6).

2. Type your valid login name on the selected SQL Server in the Login text box. If this is a new session, your login name defaults to whatever you specied for Login Name when selecting global connection preferences; otherwise, it defaults to your current session login name preference (see Setting Connection Preferences on page 2-6). On rst connection, SQL Advantage uses the operating systems user name for platforms that support a user name. 3. Type your password, if required, in the Password text box. This text box is always initially cleared. When you type your actual password in the text box, it is not displayed; it is masked by asterisks.

2-12

Using SQL Advantage

SQL Advantage 11.0.x

Connecting to SQL Server

4. The default name that appears in the Client Host Name text box is the workstation name of your client machine that you want to connect to SQL Server. If you want, you can optionally type another client host name, or delete all text, in this text box. 5. To set specic options for a new connection, click Options; the Connect Options dialog box opens (see Figure 2-7) where you can set the following options: - Network Packet Size - Text/Image Size - Language - Client Character Set - Encrypt User Password

Figure 2-7: Connect Options dialog box

Use the spin controls to specify the size, in bytes, of the network packet in the Network Packet Size text box. The value must be a multiple of 512 bytes with a minimum allowed value of 512 bytes, and a maximum that is the maximum specied for the SQL Server conguration, up to a maximum 524,288 bytes. The default value is 512 bytes. You can override this in the command line by using the A parameter (see Appendix A, Command Line Parameters.)

SQL Advantage Users Guide

2-13

Connecting to SQL Server

SQL Advantage 11.0.x

Note You must specify the maximum network packet size before connecting; however, you may not ascertain the maximum specied for the SQL Server until after connecting. You are responsible to specify this correctly.

Use the spin controls or keyboard to specify the amount of data, in bytes, to be transferred for data in columns of text and image datatype in the Text/Image Size text box. The value must be between 1 and 231 1 bytes. The default value is 32 Kilobytes. The spin controls increment/decrement by 1024 bytes but you can specify any number in the allowable range. You can also set Text/Image size in your result preferences (see Setting Result Preferences on page 2-7). Specify your choice of language in the Language text box. Allowed values are the languages installed commonly on the client and the connected SQL Server. The default is the default language for the client; you can override this on the command line using the z parameter (see Appendix A, Command Line Parameters.) Specify which character set to use on the client in the Client Character Set text box. Allowed values are the character sets installed on the client. The default value is the character set default of the client; you can override this on the command line by using the J parameter (see Command Line Parameters). When connecting to SQL Server, SQL Advantage can initiate the login with client-side password encryption. To specify to SQL Server that password encryption for SQL Advantage is desired, select the Encrypt User Password check box. SQL Server sends back an encryption key that SQL Advantage uses to encrypt your password, and SQL Server uses the key to authenticate your password when it arrives.
Note Before attempting to connect to SQL Server using this option, determine if your SQL Server supports password encryption. Encrypt User Password is not selected by default since some SQL Servers do not support encryption.

To accept changes made to the SQL Advantage Connect dialog box, click OK. This dismisses the Connect dialog box.

2-14

Using SQL Advantage

SQL Advantage 11.0.x

Connecting to SQL Server

At any time, click Cancel to dismiss the Connect Options dialog box without accepting any changes made. 6. To initiate connection to SQL Server, click Connect. This command button is disabled until at least SQL Server and login information is entered.

Indication of Successful Connection


After you successfully connect to SQL Server, your connection status shows READY in the session window status bar (see Figure 1-3 on page 1-18). If you fail to connect, an alert message informs you that the connection failed.

Multiple Connections
You can have multiple connections to one or more servers. Each connection is maintained within a different session window. The target session window can have a connection belonging to a different login or be connected to a different SQL Server. Use the Window menu to choose a window, or just click anywhere in the target session window to switch from one session to another.

Disconnecting from SQL Server


Note You cannot disconnect while there are active queries executing. You must rst cancel any pending queries before attempting to disconnect.

To disconnect a particular session, choose Disconnect from the Server menu. The SQL Server connection for the active session window is dropped, and the following occurs: The session window remains open, and any text in the query pane remains visible. The database drop-down list box on the toolbar is disabled and becomes blank. The session window status bar is updated; SQL Server, login and database names become blank.

SQL Advantage Users Guide

2-15

Using Session Windows

SQL Advantage 11.0.x

A disconnect status message is displayed in the message window pane. You can also disconnect from a SQL Server by exiting SQL Advantage, or by closing the session (see Exiting SQL Advantage on page 2-53).

Using Session Windows


A script is a collection of Transact-SQL statements used to perform a task. Scripts, stored as les, form a foundation for many SQL Server application projects. Denitions of tables, indexes, and stored procedures, as well as reports and batch jobs, are usually stored in script les. SQL Advantage may have zero, one, or more documents open at any given time, each having its own session window. Each new session window (see Figure 2-8) has a query window pane, where you enter your query scripts; and an associated message window pane, located below the query window pane, that displays messages. The message window pane is hidden if the splitter bar is pulled all the way down, and the query pane is hidden if the splitter bar is pulled all the way up.

Figure 2-8: Session window

2-16

Using SQL Advantage

SQL Advantage 11.0.x

Using Session Windows

You can open multiple session windows at any time, and easily cut, copy, and paste between them; regardless of whether you are connected or not. Both query execution errors and informational messages are sent to the message window pane. Note that fatal errors are displayed as alerts and not in the message window pane. This section covers the following session window topics: Creating query windows Opening a script le Loading a script le Connecting to a SQL Server and a database Changing database Editing scripts Executing scripts Executing selected text Executing stored procedures Checking syntax Error reporting and debugging scripts Saving scripts Printing scripts

Creating Query Windows


To open a new session window and query pane, choose New from the File menu, or click the New button on the toolbar (see Figure 1-2 on page 1-14). A new session window opens (see Figure 2-8). The caret is positioned in the top left corner of the query pane. The title of the session window is Session <n> where n is a number uniquely identifying the session window. Note that opening a new session window does not automatically establish a SQL Server connection.

Opening a Script File


Open an existing script le in any of the following ways: Choose Open from the File menu; the Open dialog box opens (see Figure 2-9).

SQL Advantage Users Guide

2-17

Using Session Windows

SQL Advantage 11.0.x

Click the Open command button on the toolbar (see Figure 1-2 on page 1-14); the Open dialog box opens (see Figure 2-9). Drag and drop script les from the Windows File Manager to your SQL Advantage workspace. Opening a script from File Manager while SQL Advantage is minimized by double-clicking an associated script or result le, restores SQL Advantage and opens a new query window containing the script. Double-click script les (*.sql or *.txt) in File Manager. Opening a script from File Manager while SQL Advantage is minimized by double-clicking an associated script or result le, restores SQL Advantage and opens a new query window containing the script.
Note To open a saved script le by double-clicking <lename>.sql or <lename>.txt in the File Manager, you must establish an appropriate association for *.sql and *.txt les.

Figure 2-9: Open dialog box

Open an existing T-SQL script from the Open dialog box as follows: 1. Select the drive and directory that contains the le you want to open, then type the name of the le you want to open in the File Name text box, or select it from the list box. The list box lists les with the lename extension selected in the List Files of Type

2-18

Using SQL Advantage

SQL Advantage 11.0.x

Using Session Windows

drop-down list box. To open a T-SQL le, select query session le type (*.sql), text le (*.txt), or results le (*.rpt). 2. Click OK to open the selected le, a new session window is displayed. The session window title is <lename>. For *.sql les, both the query and message panes of the session window contain whatever existed when the le was last saved. Additionally, the session preferences and font are restored from the le. Note, however, that SQL Server connection is not established. For *.txt les, only the query text appears in the query pane; the message pane is empty. Session preferences and font from when the le was initially saved are not remembered. 3. At any time, click Cancel to abort the le open process and dismiss the Open dialog box without attempting to open the selected le.

Loading a Script File


You can load a query script into an active session window. A new script is inserted at the current cursor location in the query window pane. If text is selected in the query window pane prior to loading a script, the new script replaces the text selection. Load an existing T-SQL script le as follows: 1. Choose Load... from the File menu; the Load dialog box opens (see Figure 2-10). 2. Select the drive and directory that contains the le you want to load, then type the name of the le you want to load in the File Name text box or select it from the list box. The list box lists les with the lename extension selected in the List Files of Type drop-down list box. Select query session le type (*.sql) or text le type (*.txt). 3. Click OK to load the selected le, a new session window is displayed. The session window title is <lename>. The session window query pane contains a combination of what was already in the query window pane with the contents of the script le being loaded inserted at the current insertion point. The session window message pane contains whatever existed when the le was last saved. Additionally, the session preferences and font are restored from the le. Note, however, that SQL Server connection is not established.

SQL Advantage Users Guide

2-19

Using Session Windows

SQL Advantage 11.0.x

4. At any time, click Cancel to abort the load le process and dismiss the Load dialog box without attempting to load the selected le.

Figure 2-10: Load dialog box

Connecting to a SQL Server and a Database


You can use SQL Advantage without any database connections as a general T-SQL capable editor. You may formulate or edit existing TSQL statements and save them to disk. You may reload and view a previously saved query and its result sets. Before you can execute a script, you must establish a SQL Server connection. To do this, see Connecting to SQL Server on page 2-11. If you try to execute a query from within a query window that does not have a connection, the Connect dialog box opens (see Figure 2-6). If the currently active session window has no connection, after you have successfully connected to SQL Server, your login name, the SQL Server name, and your default database name are updated on the session status bar (see Figure 1-3 on page 1-18), and your default database name is shown in the database drop-down list box on the toolbar (see Figure 1-2 on page 1-14). If the connection fails, an alert is displayed with a message to inform you about the failed connection.

2-20

Using SQL Advantage

SQL Advantage 11.0.x

Using Session Windows

Changing Database
The drop-down list box on the toolbar (see Figure 1-2 on page 1-14) lists all the available databases from the current sessions connected SQL Server. To quickly change from one database to another within a connected session to SQL Server, click the appropriate database name in the drop-down list box on the toolbar. You can also change from the current database to a different one, within a connected session to SQL Server, by executing a use <database> command from the query window. Changing your database updates the database name in the session windows status bar, if visible.
Note When you create a new database or drop database in the query window pane, the database drop-down list in the toolbar is not updated. To update the database list in this case, choose Refresh Lists from the View menu (see View Menu on page 1-9).

Editing Scripts
You can perform the following script editing tasks in query windows: Navigate query windows Select text Cut, copy, and paste text Clear text Undo last text edit operation Find text Find and replace text Change fonts Navigating Windows Use the keyboard and mouse to move the cursor in all text areas. Besides using the arrow keys, you can also use the Home, End, Page Up, Page Down keys, and their control key modiers.

SQL Advantage Users Guide

2-21

Using Session Windows

SQL Advantage 11.0.x

Selecting Text Select text by clicking and dragging the mouse, or by double-clicking individual words (delimited by white space). Select text with the keyboard by holding down the shift key and controlling the endpoint using the navigation techniques. Use the keyboard in conjunction with the mouse to select a range of text. Position the mouse at one end of the text to be selected and move the mouse cursor to the other end. Select the entire range of text between these two points by holding down the shift key while clicking the left mouse button. To select all the text, choose Select All from the Edit menu. Extend or reduce the selection area by holding the shift key down while altering the selection. Cutting, Copying, and Pasting Text Cut and copy operations act only upon the currently selected text. The cut operation removes the text from the editor and places it in the Clipboard. The copy operation copies the selected text into the system Clipboard, without altering it or removing it from the editor. The paste operation is the reverse of the cut operation; it takes the contents of the Clipboard and copies it into the edit window at the current insertion point. Place the insertion point anywhere within the document, or preselect a block of text to be overwritten by the contents of the Clipboard. Choose Cut, Copy, or Paste from the Edit menu, or choose Cut, Copy, or Paste from the pop-up menu that appears when you click the right mouse button. Alternatively, select the Cut, Copy, and Paste command buttons on the toolbar. Clearing Text Clear text in one of the following ways: Select the text, and press the Delete key. Select the text, and press the Backspace key. Press the Backspace key repeatedly to clear the preceding text, one character at a time.

2-22

Using SQL Advantage

SQL Advantage 11.0.x

Using Session Windows

Press the Delete key repeatedly to clear the subsequent text, one character at a time. Select the text, then choose Clear from the Edit menu. None of these operations places text in the Clipboard. Undoing Last Text Edit Operation To undo the last text operation on the current window, choose Undo from the Edit menu, or click the Undo button on the toolbar (see Figure 1-2 on page 1-14). Note that the undo operation is local to each text window. Choose Undo from the Edit menu, or click the Undo button, a second time to undo the Undo operation (that is, redo). Operations that can be undone are: Cut Copy Paste Clear Keyboard input If the last operation cannot be undone, or there is nothing to undo, the Undo command in the Edit menu is disabled. Finding Text To search for specic text sequences within the current window: 1. Choose Find... from the Edit menu, or click the Find button on the toolbar (see Figure 1-2 on page 1-14), the Find dialog box opens (see Figure 2-11). 2. The previous search string (if any) appears within the Find What text box so you can repeat the previous search operation. If this is the rst time you have invoked a search in the current session, or you wish to nd a different text string, enter the text that you want to search for in this text box. The Find function supports only simple (exact) searches; it does not support use of wildcards. Also, search strings cannot contain embedded carriage returns.

SQL Advantage Users Guide

2-23

Using Session Windows

SQL Advantage 11.0.x

Figure 2-11: Find dialog box

3. To select the search direction, select the Up or Down option button. The default is search Down selected. 4. If you want to match case for the text search string, select the Match Case check box. The default is Match Case not selected. 5. If you want to wrap the search, select the Wrap Around check box. If Wrap Around is set and you initiate a search downward from the current insertion point, and the search text is not found, the search will continue from the beginning of the document and end at the insertion point. Similarly, you search in the up direction without success, the system will continue from the end of the document back to the insertion point. The default is Wrap Around not selected. 6. To initiate the search, click Find Next. This command button is disabled until at least one character is entered in the Find What text box. The Find dialog box remains open until you close it explicitly by using the Cancel command button. Finding and Replacing Text The Find and Replace function behaves in much the same manner as the Find function; however, it lets you replace the search text (Find What) with a new string (Replace With) in any window where you can replace text. Replacing text is disabled in grid output result windows. To nd and replace specic text sequences within the current window:

2-24

Using SQL Advantage

SQL Advantage 11.0.x

Using Session Windows

1. Choose Replace... from the Edit menu, the Replace dialog box opens (see Figure 2-12).

Figure 2-12: Replace dialog box

2. The previous search string (if any) appears within the Find What text box so you can repeat the previous search operation. If this is the rst time you are invoking a search in the current session, or you if wish to nd a different text string, enter the text that you want to search for in this text box. The Find function supports only simple (exact) searches; it does not support use of wildcards. Also, search strings cannot contain embedded carriage returns. 3. If you want to match case for the text search string, select the Match Case check box. The default is Match Case not selected. 4. If you want to wrap the search, select the Wrap Around check box. When Wrap Around is set and you initiate a search, and the search text is not found between the insertion point and the end of the document, the search will wrap around to the beginning of the document and continue from there back to the insertion point. The default is Wrap Around not selected. 5. To initiate the search and nd the next occurrence of the search string, click Find Next. The search commences and the cursor stops at the rst occurrence of the search string with the search string highlighted in reverse video. This command button is disabled until at least one character is entered in the Find What text box. 6. To replace the current occurrence of the search string, and nd the next occurrence, click Replace. To replace all occurrences of the search text without stopping and prompting at each occurrence, click Replace All.

SQL Advantage Users Guide

2-25

Using Session Windows

SQL Advantage 11.0.x

The Replace dialog box remains open until you close it explicitly by using the Cancel command button. Changing Fonts To alter the font for the current session or result window: 1. Choose Font... from the Edit menu; the Font dialog box opens (see Figure 2-13). When invoked, the Font dialog box opens with the current window font selected. Font changes apply to the entire window text and cannot be undone.

Figure 2-13: Font dialog box

2. Type the name of a desired font in the Font text box, or select one from the list box of available fonts. The default font is System. 3. Type the desired font style in the Font Style text box, or select one from the list box of available font styles. The default style is Bold. 4. Type the desired font size in the Size text box, or select one from the list box of available point sizes for the selected font. The sample text box shows a preview of the font, style, and size you have selected. 5. To accept selections made in the Font dialog box and dismiss the dialog box, click OK.

2-26

Using SQL Advantage

SQL Advantage 11.0.x

Using Session Windows

6. To dismiss the Font dialog box without accepting changes, click Cancel. Font settings are saved with query session les (*.sql). You can also set fonts when setting miscellaneous preferences.

Executing Scripts
To execute a query script, choose Execute Query from the Query menu, or click the Execute button on the toolbar (see Figure 1-2 on page 1-14). If the query pane is empty, the Execute Query command is disabled. SQL Advantage submits the script, taken from the query pane, to SQL Server for execution. The current SQL Advantage session then waits for SQL Server to process the script. If you want to abort execution of the script while the execution is still in progress, see Cancelling Execution of a Script on page 2-31. During execution of a script, you can switch to another query window or another Windows-based application by clicking anywhere in the corresponding window to make the window active on the desktop. While in another query window, you can edit or execute other scripts. After the script execution is completed, the status on the session window status bar changes to READY (see Session Window Status Bar on page 1-17). SQL PRINT statement results appear in the message window pane unless you set a preference that direct them to a result window (see Setting Result Preferences on page 2-7). After the script execution is completed, all error messages (if any) are retrieved from SQL Server and appear in the message pane. All results are displayed in one or more result windows, depending upon how preferences are set.

Executing Batch Scripts


A script can consist of one or more batches separated by a batch delimiter. A batch can be any T-SQL command, including compute statements, but excluding cursor statements. The default batch delimiter is the word go. No delimiter is required for a single batch. For more information, see the Transact-SQL Users Guide.

SQL Advantage Users Guide

2-27

Using Session Windows

SQL Advantage 11.0.x

If you type GO <n> as your delimiter, where n is an integer, the T-SQL command repeats n times before executing the next command in the batch. You may execute a script with only one T-SQL query statement. In this case, SQL Advantage uses the end of text to mark the end of a query statement. However, when multiple query statements are combined in a batch to be executed together, terminators are required to mark the end of certain T-SQL query statements (see Figure 2-14). Enter the terminator on a new line after the T-SQL query statement. The terminator for the last T-SQL statement at the end of the script is optional. You can dene the terminator when setting Query Preferences in the Preferences dialog box. If you want to abort execution of the batch while the execution is still in progress, see Cancelling Execution of a Script on page 2-31.

Figure 2-14: Sample batch script

Executing Selected Text


To select a portion of the entire script within the query window to be submitted to SQL Server for execution, select the text (see Figure 2-15) using standard Windows text selection methods, then choose Execute Selection from the Query menu, or click the Execute button on the toolbar (see Figure 1-2 on page 1-14). If you do not select any text, the whole script in the query window is executed.

2-28

Using SQL Advantage

SQL Advantage 11.0.x

Using Session Windows

If you want to abort execution of the script while the execution is still in progress, see Cancelling Execution of a Script on page 2-31.

Figure 2-15: Selected script text

Executing Stored Procedures


To execute stored procedures: 1. To access the Execute Stored Procedure dialog box, either: - Choose Execute Stored Procedure... from the Query menu, or - Select a procedure from the Stored Procedure pick list (see Using the Stored Procedures Pick List on page 2-39) and click the Execute command button. The Execute Stored Procedure dialog box opens (see Figure 2-16). 2. When the Execute Stored Procedure dialog box rst opens, the drop-down list box is lled with stored procedures taken from the currently used database, the system database sybsystemprocs (the system stored procedures) for SQL Server release 10.0 and later; and from the master database if SQL Server pre-release 10.0. If invoked from the Query menu, and this is the rst time the Execute Stored Procedure dialog box opens, nothing is selected. If the dialog box was used before during the current session, the previously selected stored procedure is selected by default.

SQL Advantage Users Guide

2-29

Using Session Windows

SQL Advantage 11.0.x

If invoked from the stored procedure pick list (see Using the Stored Procedures Pick List on page 2-39), the procedure from the pick list is selected by default.

Figure 2-16: Execute Stored Procedure dialog box

3. Select the desired stored procedure by scrolling through the drop-down list. The corresponding parameters, their datatypes, whether they are outputs, and their default values from the stored procedure are displayed in the multicolumn list. A check mark is displayed in the output cell for each output parameter. For each parameter with a default, default values are prelled in the value cell. The number of parameters displayed depends upon the font used. View additional unseen parameters by scrolling. Use the cursor keys to move up and down the list. You can also use the Enter key to move down the list. Click the parameter of interest; it is displayed in the read-only text boxes at the top of the list. 4. Enter an appropriate value in the Value text box to be used when the procedure executes. The value must be consistent with the datatype for that parameter.

2-30

Using SQL Advantage

SQL Advantage 11.0.x

Using Session Windows

5. All non-output parameters require a value set. For strings, no value implies an empty string; that is, . Quotation marks are optional for strings. Binary strings can be optionally preceded with 0x. Money values can be optionally preceded with $. After all non-output parameters have values, the Execute command button is enabled. 6. Click Execute. This dismisses the dialog box. After the stored procedure execution is completed, the status on the session window status bar changes to READY (see Session Window Status Bar on page 1-17). SQL PRINT statement results appear in the message window pane unless you set a preference that direct them to a result window (see Setting Result Preferences on page 2-7). All error messages (if any) are retrieved from the SQL Server and are displayed in the message pane. Results are displayed in one or more result windows, depending upon preferences. 7. To cancel the operation for any reason, click Cancel, or choose Close from the Control menu.

Cancelling Execution of a Script


To cancel the execution of a query script, choose Cancel Query from the Query menu, or click the Cancel button on the toolbar (see Figure 1-2 on page 1-14). The status on the session window status bar (see Session Window Status Bar on page 1-17) changes to CANCELLING and then to READY after the cancelling operation is completed. After cancelling a query script, all results of the query after the cancellation are lost; any previously opened result windows, if any, are retained.

Checking Syntax
When setting query preferences (see Setting Query Preferences on page 2-4), select the No Execute (compile only) check box to make SQL Server compile the query script without executing it. Select the Parse Query Only check box to parse the query script to check the syntax.

SQL Advantage Users Guide

2-31

Using Session Windows

SQL Advantage 11.0.x

When the query is compiled or parsed, SQL Server rejects any erroneous statements, and displays error messages in the session window message pane (see Figure 2-8).

Error Reporting and Debugging Scripts


When SQL Server rejects a script during execution, it returns one or more error messages, which are displayed in an error list in the message window pane. When you double-click an error in the error list, SQL Advantage positions the text cursor in the query window to point to the rst line of the query block in your script being executed when the error occurred. Every error message is logged into a log le specied when you set your global miscellaneous preferences (see Setting Miscellaneous Preferences on page 2-10).

Saving Scripts
To save a query script, or to save a set of results: 1. Choose Save from the File menu, or click the Save button on the toolbar. The rst time you save a window to a le, the Save As dialog box (see Figure 2-17) opens to prompt you to specify the le name; thereafter, the le is saved immediately with no dialog prompt.

Figure 2-17: Save As dialog box

2-32

Using SQL Advantage

SQL Advantage 11.0.x

Using Session Windows

To save an existing script or set of results under another name, choose Save As... from the File menu. 2. In the Drives list box, select the drive to contain the le you want to save. 3. In the Directories list box, select the directory to contain the le you want to save. 4. To save to shared directories on the network, click Network to open the Connect Network Drive dialog box. See the Microsoft Windows Users Guide for instructions on saving to shared directories. 5. In the File Name text box, type a name for the le you want to save, or select it from the list box. 6. In the Save File As Type drop-down list, select either a session or text le type. For session windows: - A session le contains the query script and all associated messages and preferences. The default extension is .sql. - A text le contains only the query script. The default extension is .txt. 7. After you have selected the le characteristics and storage location, click OK to save the le. After saving for the rst time, the window title will change to <lename>. 8. Click Cancel to abort the save process and dismiss the Save As dialog box without attempting to save the le.

Printing
You can print the contents of the query pane, message pane, or result window (in either grid or text output mode). Before you send your documents to print, perform the page setup procedure to set up your printed page. Page Setup To set up the printed page: 1. Choose Page Setup from the File menu. The page setup dialog box opens (see Figure 2-18). Use this dialog box to set headers, footers, margins, and order for printing a report with more than one page.

SQL Advantage Users Guide

2-33

Using Session Windows

SQL Advantage 11.0.x

Figure 2-18: Page Setup dialog box

2. Type any printable characters for your page header in the Header text box. You can also use three optional substitution markers in the header, as follows: - On the printout, the &f command prints the current le name. If no le name is available, the window title is printed. - On the printout, the &p command prints the current page number. - On the printout, the &d command prints the system date and time. 3. Type any printable characters for your page footer in this text box. You can also use the three optional substitution markers, &f, &p, and &d in the footer as described in Step 2 for the header. 4. Type the left, right, top, and bottom page margins, in inches, in the appropriate text boxes. Range is from 0 to 3 inches. 5. If you want to print multiple-page text or result windows, select the appropriate option button to dene the order in which to print, either; - Across, then Down - Down, then Across

2-34

Using SQL Advantage

SQL Advantage 11.0.x

Using Session Windows

6. Click OK to accept your page set up parameters, or click Cancel to cancel any changes made. Printing Scripts You can print the contents of the query pane, message pane, or result window (in either grid or text output mode). To print the contents of your session window query pane or message pane: 1. Click in the pane you want to print to give it focus, then choose Print... from the File menu, or click the Print button on the toolbar. A standard Windows Print dialog box opens (see Figure 2-19).

Figure 2-19: Print dialog box

2. To print a full document, select the All option button in the Print dialog box. To print a range of pages in the document, select the Pages option button in the Print dialog box, then enter the page number range in the From and To text boxes. If you want to print only one page, just enter the page number in the From text box. To print only selected text in the window pane, select the Selection option button in the Print dialog box. Note that in a

SQL Advantage Users Guide

2-35

Using Query Construction Tools

SQL Advantage 11.0.x

result window in grid output, you can select only a contiguous group of cells, rows, or columns to print. 3. To send your print job to the printer, click OK. See the Microsoft Windows Users Guide for more information.

Using Query Construction Tools


To enhance accuracy and increase productivity, SQL Advantage provides powerful and easy-to-use query construction tools such as pick lists, join construction, and historical recall of previous queries. Pick lists are list boxes that list information representing underlying data, such as tables and columns, views and columns, and stored procedures from the current database; and T-SQL commands syntax and system procedures syntax from the current SQL Server. You can easily paste syntactically correct table and column names, view and column names, stored procedures, T-SQL command syntax, and system procedure syntax from SQL Advantage pick lists into the script text. SQL Advantage also helps you to construct joins by means of a Join Selection dialog box that displays column join candidates for any two selected tables or views. And nally, you can recall previous queries by means of the History dialog box which displays the ten last recorded scripts for the active query session.

Using the Tables and Columns Pick List


To insert table and column names into the query window: 1. Choose Pick Lists from the View menu, then choose Tables & Columns from the cascading menu that appears. If the current session window has focus, the Tables and Columns pick list opens. This pick list is sensitive to the current session windows database connection and updates when the connection changes. The Tables and Columns pick list (see Figure 2-20) is formatted in hierarchical fashion with each top level item representing the table with its columns indented beneath it. The tables are displayed in alphabetical order by table name. If the owner is not dbo, the owner name follows the table name, in parentheses.

2-36

Using SQL Advantage

SQL Advantage 11.0.x

Using Query Construction Tools

Figure 2-20: Tables and Columns pick list

2. Update the pick list at any time by choosing Refresh Lists from the View menu. 3. Click the collapse () or explode (+) buttons in the pick list next to the table name to hide or expose the indented columns directly beneath it. 4. Select a list entry and note that it appears at the bottom of the pick list dialog box. If you have a table selected, you can prex the table name with the owner's name by selecting the Owner check box. If you have a column selected, you can prex the column with the table name by selecting the Table check box. 5. Click Paste, or double-click the list entry, to paste it into the active query window at the current insertion point. You can select only one item at a time. If a query is executing in the current session window, the Paste command button is disabled. 6. The Tables and Columns pick list remains open until you close it in either of the following ways: - In the pick list, double-click the Close box in the upper left corner of the pick list. - In the cascading Pick Lists submenu of the View menu, choose Tables & Columns; the check mark next to this command disappears.

SQL Advantage Users Guide

2-37

Using Query Construction Tools

SQL Advantage 11.0.x

Using the Views and Columns Pick List


To insert view and column names into the query window: 1. Choose Pick Lists from the View menu, then choose Views & Columns from the cascading menu that appears. If the current session window has focus, the Views and Columns pick list opens. This pick list is sensitive to the current session windows database connection and updates itself when the connection changes. The Views and Columns pick list (see Figure 2-21) is formatted in hierarchical fashion with each top level item representing the view with its columns indented beneath it. The views are displayed in alphabetical order by view name. If the owner is not dbo, the owner name follows the view name, in parentheses.

Figure 2-21: Views and Columns pick list

2. Update the pick list at any time by choosing Refresh Lists from the View menu. 3. Click the collapse () or explode (+) buttons in the pick list next to the view name to hide or expose the indented columns directly beneath it. 4. Select a list entry and note that it appears at the bottom of the pick list dialog box. If you have a view selected, you can prex the view name with the owner's name by selecting the Owner

2-38

Using SQL Advantage

SQL Advantage 11.0.x

Using Query Construction Tools

check box. If you have a column selected, you can prex the column with the view name if you select the View check box. 5. Click Paste, or double-click the list entry, to paste it into the active query window at the current insertion point. You can select only one item at a time. If a query is executing in the current session window, the Paste command button is disabled. 6. The Views and Columns pick list remains open until you close it in either of the following ways: - In the pick list, double-click the Close box in the upper left corner of the pick list. - In the cascading Pick Lists submenu of the View menu, choose Views & Columns; the check mark next to this command disappears.

Using the Stored Procedures Pick List


The pick list for Stored Procedures lists stored procedures, including the system stored procedures, in alphabetical order. If the owner is not dbo, the owner name follows the stored procedure name, in parentheses. You can easily insert stored procedure names into the script text editor. You can also execute them from this pick list. To insert stored procedure names into the query window pane, and execute them: 1. Choose Pick Lists from the View menu, then choose Procedures from the cascading menu that appears; the stored procedures pick list opens (see Figure 2-22). This pick list is sensitive to the current session windows database connection and updates when the connection changes. 2. Update this pick list at any time by choosing Refresh Lists from the View menu. 3. To paste a stored procedure name into the active query window at the current insertion point, select a stored procedure from the list and click Paste, or double-click the stored procedure name in the list.

SQL Advantage Users Guide

2-39

Using Query Construction Tools

SQL Advantage 11.0.x

Figure 2-22: Stored Procedures pick list

4. To execute the selected stored procedure, click Execute. This invokes the Execute Stored Procedure dialog box (see Figure 2-16), if parameter values are required; otherwise it executes immediately. 5. The Stored Procedures pick list remains open until you close it in either of the following ways: - In the Stored Procedures pick list, double-click the Close box in the upper left corner of the pick list. - In the cascading Pick Lists submenu of the View menu, choose Procedures; the check mark next to this command disappears.

Using the T-SQL Syntax Pick List


The T-SQL Syntax pick list lists T-SQL commands, in alphabetical order. You can easily insert T-SQL commands into the script text editor from this pick list.
Note The T-SQL Syntax pick list is disabled if you are not connected to SQL Server release 10.0 or later, or if the sp_syntax stored procedure is not fully installed on the SQL Server to which you are connected.

To insert a T-SQL command into the query window:

2-40

Using SQL Advantage

SQL Advantage 11.0.x

Using Query Construction Tools

1. Choose Pick Lists from the View menu, then T-SQL Syntax from the cascading menu that appears. The T-SQL Syntax pick list opens (see Figure 2-23). This pick list is sensitive to the current session windows SQL Server connection and updates itself when the connection changes. This pick list is static for the selected SQL Server and is not updated when you choose Refresh Lists from the View menu.

Figure 2-23: T-SQL Syntax pick list

2. To paste a description of the command and its syntax into the active query window at the current insertion point, select a TSQL command from the list and click Paste, or double-click the selected T-SQL command name in the list.
Note You can select only one T-SQL command at a time.

3. The T-SQL Syntax pick list remains open until you close it in either of the following ways: - In the T-SQL Syntax pick list, double-click the Close box in the upper left corner of the pick list. - In the cascading Pick Lists submenu of the View menu, choose T-SQL Syntax; the check mark next to this command disappears.

SQL Advantage Users Guide

2-41

Using Query Construction Tools

SQL Advantage 11.0.x

Using the System Procedures Syntax Pick List


The System Procedures Syntax pick list lists system procedures, in alphabetical order. You can easily insert the syntax for system stored procedures into the script text editor.
Note The Procedures Syntax pick list is disabled if you are not connected to SQL Server release 10.0 or later, or if the sp_syntax stored procedure is not fully installed on the SQL Server to which you are connected.

To insert system procedures syntax into the query window pane: 1. Choose Pick Lists from the View menu, then choose System Procedures Syntax from the cascading menu that appears. The System Procedures Syntax pick list opens (see Figure 2-24). This pick list is sensitive to the current session windows SQL Server connection and updates when the connection changes. This pick list is static for the selected SQL Server and is not updated when you choose Refresh Lists from the View menu.

Figure 2-24: System Procedures Syntax pick list

2. To paste a description of the procedure and the system procedure syntax into the active query window, at the current insertion point, select a system procedure in the list and click Paste, or double-click a selected system procedure in the list.

2-42

Using SQL Advantage

SQL Advantage 11.0.x

Using Query Construction Tools

Note You can select only one system procedure command at a time.

3. The Procedures Syntax pick list remains open until you close it in either of the following ways: - In the Procedures Syntax pick list, double-click the Close box in the upper left corner of the pick list. - In the cascading Pick Lists submenu of the View menu, choose System Procedures Syntax; the check mark next to this command disappears.

Constructing Joins
SQL Advantage helps you to construct joins by means of a Join Selection dialog box that displays column join candidates for any two selected tables or views (similar to the output from the system stored procedure, sp_helpjoins). To construct joins: 1. Before invoking the Join Selection dialog box, position the cursor in the where clause or the having clause of the query where the constructed join condition is to be inserted. No checks are performed to ensure the correctness of the resulting query. 2. Choose Joins... from the Query menu; the Join Selection dialog box opens (see Figure 2-25).

Figure 2-25: Join Selection dialog box

SQL Advantage Users Guide

2-43

Using Query Construction Tools

SQL Advantage 11.0.x

The Table/View drop-down lists are originally populated with a list of tables and views from the current sessions database. If the owner is not dbo, the table and view names are followed by the owner name, in parentheses. 3. To set up the desired join conditions: 1. Select a table or view from the left Table/View drop-down list. 2. Select a table or view from the right Table/View drop-down list. 3. To obtain a list of available join conditions, click Show Joins. If no join candidates are found, a message appears in a popup box. 4. Select one or more conditions from the Available Join Conditions list. Initially, all are selected. 5. To add new join conditions to the Join Conditions list, click the right-facing arrow command button (>>). This automatically moves the selected items from the Available Join Conditions list into the Join Conditions list. Alternatively, double-click on an available join condition to add it as a new join condition. 6. To remove a join condition from the Join Conditions list box, select it in the Join Conditions list (right list box) and click the left-facing arrow command button (<<). This action moves one or more items from the Join Conditions list box and restores them to the Available Join Conditions list. 7. To insert the selected join conditions at the current cursor location in the query window, click Paste. Clicking Paste also dismisses the dialog box and returns you to the query window where the join condition is inserted on a new line following the current cursor location. 8. To close the dialog box at any time, click Cancel, or alternatively, double-click the close bar in the upper left corner of the dialog box, or click the close bar and choose Close from the dialog control menu.

Recalling a Previous Query


To recall and execute a previously recorded query, or record the currently selected text in the query window, choose History... from the Query menu; the History dialog box opens (see Figure 2-26).

2-44

Using SQL Advantage

SQL Advantage 11.0.x

Using Query Construction Tools

The History dialog box displays the ten last recorded scripts for the active query session. For ease of display and script identication, leading white space is stripped and embedded carriage returns are removed.

Figure 2-26: History dialog box

When you select a script in the upper list box, it is displayed in its entirety in the lower read-only Entire Selected Script edit pane. Scroll the script to see more of the script text, if necessary. There are two modes for recording scripts in the history facility: Automatic In automatic history recording mode, each query window script is loaded automatically into the list box when executed. Select the Automatic Script Recording check box for automatic script recording mode. You can also change the history recording mode in the Query Preferences dialog (see Setting Query Preferences on page 2-4). Manual You can use the Record command button to manually record a script from the query window into the list box in both manual and automatic recording modes.. If there is a script in the session window with current focus, and part of its text is selected, only the selected text is recorded. Otherwise, the whole script in that query window pane is recorded.

SQL Advantage Users Guide

2-45

Using Result Windows

SQL Advantage 11.0.x

The Record button is disabled if there is no text in the query window pane. To paste a previous query into the query window at the current cursor location, select a script from the list, and click Paste. The selected script replaces any selection in the query window pane, or appears at the current cursor position if there is no selection. The History dialog box closes. To execute the selected script in the current session window, using that sessions connection and query preferences, and dismiss the dialog box, click Execute, or double-click the selected script in the list. To delete the selected script from the history list box, click Delete. To dismiss the History dialog box, click Close.

Using Result Windows


Result windows appear following the successful execution of a query. Result window contents are displayed as text or in a grid. You specify this feature when you set result window preferences (see Setting Result Preferences on page 2-7). The default result window display is text. You can edit the results data using standard Windows editing functions such as cut, copy, and paste. See SQL Advantage Result Windows on page 1-18 for types of result windows and result window text output and grid output modes.

Opening Result Files


Open an existing results le in any of the following ways: Choose Open from the File menu; the Open dialog box opens (see Figure 2-9 on page 2-18). Click the Open command button on the toolbar; the Open dialog box opens (see Figure 2-9). Drag and drop results les from the Windows File Manager to your SQL Advantage workspace. Double-click a results le (*.rpt) in the Windows File Manager.

2-46

Using SQL Advantage

SQL Advantage 11.0.x

Using Result Windows

Note To open a saved results le by double-clicking <lename>.rpt in the File Manager, you must establish an appropriate association for *.rpt les.

Editing Result Windows in Text Output Mode


You can perform the following editing tasks in result windows in text output mode: Navigate text result windows Select text Cut, copy, and paste text Clear text Undo the last edit operation Find text Find and replace text Change fonts Navigate and edit result windows in text output mode by using the same techniques described for session windows (see Editing Scripts on page 2-21.

Editing Result Windows in Grid Output Mode


You can perform the following editing tasks in result windows in grid output mode: Navigate grid result windows Select cells Edit cell contents Copy cell contents Select rows Resize rows Copy rows Select columns Resize columns

SQL Advantage Users Guide

2-47

Using Result Windows

SQL Advantage 11.0.x

Copy columns Navigating Grid Output Result Windows In grid output mode, use the keyboard and mouse to move the cursor in all cell areas using standard Windows techniques as described in the Microsoft Windows Users Guide. Besides using the arrow keys, you can also use the Home, End, Page Up, Page Down keys and their control key modiers. For cell navigation in grid output result windows, you can also use the Tab, Shift Tab, and Enter keys. Selecting Cells To select an entire cell, click anywhere in the cell. To select a contiguous block of cells as a group of rows, columns, or rows and columns, click in an end cell, hold down the mouse button and drag the mouse. To select all the cells, click in the empty cell at the leftmost side of the heading row, or click in any other cell, then choose Select All from the Edit menu. You may not select a subset of the text within a cell. Editing Cell Contents To edit the full contents of a selected cell, double-click the cell containing the text you want to edit, or alternatively, click in the cell then choose Edit Cell... from the View menu; the Edit Cell dialog box opens (see Figure 2-27). You can perform standard text editing operations within this dialog box.
Note The edited cell content does not alter data in the database, that is you cannot update the database by editing the results.

Before you can perform any other work, click OK to accept your editing changes, or click Cancel to cancel the edit cell operation.

2-48

Using SQL Advantage

SQL Advantage 11.0.x

Using Result Windows

Figure 2-27: Edit Cell dialog box

Copying Cell Contents To copy cell contents: 1. Click or tab to select a cell. 2. Choose Copy from the Edit menu. Selecting Rows Before you can perform any standard spreadsheet functions on rows, you must rst select the rows on which you want to operate. Selecting a Single Row To select a single row, click the numbered row heading on the lefthand side of the row. The selected row displays in reverse video. Selecting a Contiguous Range of Cells in a Row To select a contiguous range of cells in a row:

SQL Advantage Users Guide

2-49

Using Result Windows

SQL Advantage 11.0.x

1. Select one cell to be the left or right end of your contiguous range. 2. Hold down the mouse button and drag the mouse to the right or left to add cells to your desired range. Selecting a Contiguous Range of Rows To select a contiguous range of rows: 1. Click the numbered row heading of the rst or last row in the desired range. The selected row displays in reverse video. 2. Hold down the mouse button and drag the mouse downwards or upwards until you have selected all the rows in the desired range. Resizing Rows To adjust the height of the heading row only, click and drag the lower bar in the leftmost cell of the heading row to the desired row size. To resize all other rows, click and drag the lower bar of any numbered cell at the leftmost side of the row to the desired row size.
Note Resizing any row, other than the heading row, resizes all rows, other than the heading row.

Copying Rows You can perform copy operations on rows, just as you can on individual cells. To copy rows: 1. Click the numbered row heading on the left-hand side of the row to select the row. The selected row displays in reverse video. 2. Choose Copy from the Edit menu. Selecting Columns Before you can perform any standard spreadsheet functions on columns, you must rst select the columns on which you want to operate.

2-50

Using SQL Advantage

SQL Advantage 11.0.x

Using Result Windows

Selecting a Single Column To select a single column, click the column heading above the rst row of the column. The selected column displays in reverse video. Selecting a Contiguous Range of Cells in a Column To select a contiguous range of cells in a column: 1. Select one cell to be the top or bottom cell in the contiguous range. 2. Hold down the mouse button and drag the mouse down or up to add cells to the desired range. Selecting a Contiguous Range of Columns To select a contiguous range of columns: 1. Click the column heading of the rst or last column in the desired range. 2. Hold down the mouse button and drag the mouse left or right until you have selected all the columns in the desired range. Resizing Columns To resize any column: 1. Click the vertical bar at the right hand side of the column in the header row. 2. Hold down the mouse button and drag the bar to the desired width. Copying Columns You can perform copy operations on columns, just as you can on rows: 1. Click the column heading above the rst row. The selected column displays in reverse video. 2. Choose Copy from the Edit menu.

SQL Advantage Users Guide

2-51

Using Result Windows

SQL Advantage 11.0.x

Finding Text in Grid Output Result window You can search for text sequences within the current grid output result window; the grid cell containing the text string becomes highlighted. The nd procedure is the same as described in Finding Text on page 2-23.

Printing Results
Printing results is the same procedure as described for Printing Scripts on page 2-35.

Saving Results
You can save the contents of a result window and the font to a specied lename. A saved result window in grid output mode is reopened as a grid window. Its formatted options are saved with the result le. To save a set of results: 1. Choose Save from the File menu, or click the Save button on the toolbar. The rst time you save a result window to a le, the Save As dialog box (see Figure 2-17 on page 2-32) opens to prompt you to specify the le name; thereafter, the le is saved immediately with no dialog prompt. To save an existing set of results under another name, choose Save As... from the File menu. If SQL Advantage has no query windows open, result windows open, or if no changes have been made since the window was last saved, this command is disabled. 2. In the Drives list box, select the drive to contain the le you want to save. 3. In the Directories list box, select the directory to contain the le you want to save 4. To save to shared directories on the network, click Network to open the Connect Network Drive dialog box. See Microsoft Windows Users Guide for instructions on saving to shared directories.

2-52

Using SQL Advantage

SQL Advantage 11.0.x

Exiting SQL Advantage

5. In the File Name text box, type a name for the le you want to save, or select it from the list box. 6. In the Save File As Type drop-down list, select the results le type. The default extension is .rpt. 7. After you have selected the le characteristics and storage location, click OK to save the le. After saving for the rst time, the window title will change to <lename>. 8. Click Cancel to abort the save process and dismiss the Save As dialog box without attempting to save the le.

Exporting Data to Other Products


You can export data from your SQL Advantage result windows to traditional spreadsheet applications such as Microsoft Excel. You can copy part or all of the contents of a SQL Advantage results spreadsheet and paste it into your preferred spreadsheet application using standard copy and paste techniques.

Exiting SQL Advantage


When you quit SQL Advantage, after conrmation, all connections are automatically disconnected. Exit SQL Advantage in any of the following ways: In the SQL Advantage application control window, double-click the close box in the upper-left-hand corner of the window (see Figure 1-1 on page 1-2), or click the close box and choose Close from the SQL Advantage application control menu. Choose Exit from the File menu. If you selected Prompt on Unsaved Changes when setting your Miscellaneous Preferences (see Setting Miscellaneous Preferences on page 2-10), and if there are any unsaved changes in the query window, a closing message dialog opens prompting you to save the changes rst.

SQL Advantage Users Guide

2-53

Exiting SQL Advantage

SQL Advantage 11.0.x

2-54

Using SQL Advantage

Command Line Parameters

A.

SQL Advantage can be started from the command line with a subset of the option parameters supported by the command line version of
isql.

Supported Command Line Parameters


Note that SQL Advantage parameters are case-sensitive. Table A-1 lists supported parameters that you can override by user preferences. Table A-2 lists supported parameters that you cannot override by user preferences.
Table A-1: Overridable supported parameters Parameter
B b batchSize

Description
Species batch processing mode. Note that B and R are mutually exclusive. Species the batch size in rows. This determines the frequency of result window or output le update refreshes. Resets the command terminator. The default terminator is GO. Species the initial database to which you connect. Default is logins default database. Sets the client host name. Default is machine name. Species the timeout value used when connecting to SQL Server. The default timeout is 60 seconds for a SQL Server response after a logon request from SQL Advantage. Species row by row processing mode. In this mode, results are displayed as they are returned. Note this method allows handling of large result sets but is generally slower than batch processing mode. Note that B and R are mutually exclusive. Species the name of the SQL Server to connect to. SQL Advantage looks for this name in the registry or the interfaces le. Species the number of seconds before a T-SQL command times out. The default timeout is 60 seconds.

c cmdend D database H hostName l loginTimeout

S server

t timeout

SQL Advantage Users Guide

A-1

Supported Command Line Parameters

SQL Advantage Release 11.0.x

Table A-1: Overridable supported parameters (continued) Parameter


U loginName

Description
Species the login name. Default is user name.

Table A-2: Unchangeable supported parameters Parameter


A size

Description
Species the network packet size, in bytes, to use for this SQL Advantage session. Size must be between the values of the default network packet size and the maximum network packet size, in multiples of 512. Default is 512. Species the name and location of the interfaces le to search when connecting to SQL Server. Without I, SQL Advantage looks for a le named $SYBASE/ini/sql.ini in the directory specied by the $SYBASE user environment variable. If $SYBASE is not dened, an error is displayed. Species the name of a le to use for input to SQL Advantage. You must supply the full path if the le is not in the same directory as the SQL Advantage executable. If the le is not found, an error is displayed. Launches SQL Advantage as a background process. There is no graphical user interface visible. This parameter is not a Sybase ISQL parameter. Species the character set to use on the client. SQL Advantage uses a lter to convert between client_charset and the SQL Server character set. J client_charset requests that SQL Server convert to and from client_charset, the character set used on the client. Use this if the client and SQL Server use the same character set. Omitting J sets the character set to a default for the platform.

I interfaceFile

i inputFile

J client_charset

o outputFile

Species the name of a le in the current directory to store the output results (and messages, if preference is set) from SQL Advantage. Species the current users SQL Server password. Displays the About SQL Advantage dialog after launching. Initiates the login connection to the server with client-side password encryption. Species a SYBASE directory other than the default $SYBASE directory.

P password v X y sybaseDir

A-2

Command Line Parameters

SQL Advantage Release 11.0.x

Unsupported Command Line Parameters

Table A-2: Unchangeable supported parameters (continued) Parameter


z language

Description
Species an alternate language in which to display SQL Server-generated prompts and messages. Without this parameter, SQL Advantage uses the servers default language.

Unsupported Command Line Parameters


All command line parameters, other than those listed in Tables A-1 and A-2 are unsupported. See the Open Client/Server Supplement for a complete listing and descriptions of isql command line parameters.

Input/Output (I/O) Redirection


You can redirect input and results data to and from external les only from the command line. SQL Advantage supports entering the parameters listed in Table A-3 on the command line for redirection.
Table A-3: Parameters supported for redirection Parameter
i input

Description
Open SQL Advantage with the input script as specied in the input le. Once the input le is loaded, you may edit or extend the script le or add new statements. During the lifetime of the current application, you may redirect the default output to an output le by changing the output options. The output is written as a text le (*.txt) to the le specied in output. The output is redirected for the whole session and no results are displayed in the result window. All result outputs are appended to the output le. If SQL Advantage is launched with an existing output le name, it will be replaced.

o output

SQL Advantage Users Guide

A-3

Examples

SQL Advantage Release 11.0.x

Note 1.When results are redirected to an output le, it defaults to Text Output format preference. 2.An error message is displayed when you attempt to access a le without having read/write permissions on that le. 3.If the rst parameter is not preceded by the minus symbol (), the parameter is assumed to represent the input lename. 4.Spaces are not required between parameters and their values.

Examples
1. sqladv Ubarney -Ppurple -SJURASSIC

Invokes SQL Advantage with the login name barney, password purple, and SQL Server JURASSIC. If everything works correctly, the initial session will log you in and connect you.
2. sqladv -P yabbadabbadoo -U flintstone -SBEDROCK -o rocklist.txt

Logs Fred intstone into the BEDROCK SQL Server, and directs all query results to the output le named rocklist.txt. The order of the parameters does not matter.
3. sqladv yearend.txt

Brings up the editor with the input le yearend.txt preloaded into the initial session window. If you include login parameters, SQL Advantage executes the SQL statements within the input le immediately after connecting to the specied server.

A-4

Command Line Parameters

B
Error Messages

Error Messages

B.

SQL Advantage displays error messages to alert you to abnormal conditions. Table B-1 lists the most signicant SQL Advantage error messages and the corrective action to take when they appear.
Table B-1: Error Messages Error Message
Insufcient memory to initialize application. Please close other applications and try again. Application has run out of memory while <performing some task>. Cannot open the selected le. <lename> <reason> Cannot open error log le. <lename> <reason> Cannot write to log le. <lename> <reason>

Corrective Action
Your machine needs more memory. Shut down other applications and try again.

Your machine needs more memory. Close session and result windows and try again, or shut down other applications and try again. For each of these error messages, one of the following <reasons> may also be displayed: The le has an incompatible format The le was created with an earlier version of the application File access denied File I/O Error File already in use File lock violation Disk is full File cannot be found Directory containing the le cannot be found In all of the above cases, the solution to your problem should be self-evident.

Cannot nd Server <SQLServerName> in your current Open Client Conguration.

You have made a typographical error in <SQLServerName>; retype name. Run dsedit to add SQL Server <SQLServerName> to your list of servers. Open Client not using correct Directory Service Driver; run osscfg to select appropriate Directory Service Driver.

SQL Advantage Users Guide

B-1

Error Messages

SQL Advantage Release 11.0.x

Table B-1: Error Messages (continued) Error Message


Internal failure while initializing SQL Advantage. Please check that Open Client is congured correctly.

Corrective Action
Exceeded system resources: free up resources by closing windows or applications. Incorrect Open Client conguration: Check for missing interfaces le Check for error in registry Check for missing character sets or locales

Internal failure has occurred while <performing some task>. Please contact your System Administrator or Sybase Technical Support. Internal failure has occurred while initializing result data.

Contact your System Administrator or Sybase Technical Support.

Other messages should accompany this one to help you understand what to x. Most probably, something is wrong with your conguration. If you can't resolve it, contact your System Administrator or Sybase Technical Support. Other messages should accompany this one to help you understand what to x. Most probably, something is wrong with your conguration. If you can't resolve it, contact your System Administrator or Sybase Technical Support. Quit the application and report the problem to Sybase Technical Support. To prevent the logle from being overwritten, do not relaunch until after reporting the problem to Sybase Technical Support. No harm is done. Simply reconnect. Report the problem to Sybase Technical Support. No harm is done. Simply reconnect. Report the problem to Sybase Technical Support.

Internal failure has occurred, cannot open document.

Internal Error: Bad Transaction State.

The connection has dropped. Failure has occurred in CTLibrary call. Connection is no longer usable and will be automatically dropped.

B-2

Error Messages

Index
A
Application Control Menu Close 1-4 Maximize 1-4 Minimize 1-4 Move 1-3 Restore 1-3 Size 1-3 Switch to 1-4 Application Window 1-1 Control Menu 1-3 Maximize Control 1-16 Minimize Control 1-15 Restore Control 1-16 Status Bar 1-18 Automatic History Recording Mode 2-45 Connecting to a SQL Server and a Database 2-19 Connecting to SQL Server 2-11 Connect Options Client Character Set 2-14 Connect Options Dialog Box 2-13 Client Character Set 2-14 Language 2-14 Network Packet Size 2-13 Text/Image Size 2-14 Constructing Joins 2-43 Copying Cells 2-49 Copying Columns 2-51 Copying Rows 2-50 Copying Text 2-22 Creating Query Windows 2-17 Cutting Text 2-22

2.

C
Cancelling Execution 2-31 Cancelling Script Execution 2-31 Changing Database 2-21 Changing Fonts 2-26 Checking Syntax 2-31 Clearing Text 2-22 Command Line Parameters Examples A-5 Input/Output (I/O) Redirection A-4 Supported Command Line Parameters A-1 Unsupported Command Line Parameters A-4 Connect Dialog Box 2-11 Client Host Name 2-13 Connect 2-15 Login 2-12 Options 2-13 Password 2-12 Server 2-12

D
Debugging Scripts 2-32 Disconnecting from SQL Server 2-15

E
Edit Cell Dialog Box 2-49 Editing Cell Contents 2-48 Editing Result Text Windows 2-47 Editing Scripts 2-21 Edit Menu 1-8 Clear 1-9 Clear All Messages 1-9 Copy 1-8 Cut 1-8 Find 1-9 Font 1-9 Paste 1-8 Replace 1-9 Select All 1-9 Undo 1-8 Encrypt User Password 2-14 Index-1

SQL Advantage Users Guide

SQL Advantage 11.0.x

Error Messages B-1 Error Reporting 2-32 Execute Stored Procedures Dialog Box 2-30 Executing Batch Scripts 2-27 Executing Scripts 2-21, 2-27 Executing Selected Text 2-28 Executing Stored Procedures 2-29 Exiting SQL Advantage 2-53 Exporting Data to Other Products 2-53

Manual 2-45

I
Indication of Successful Connection 2-15 Introduction 2-1

J
Joins 2-43 Joins Selection dialog box 2-43

F
File Menu 1-4 Close 1-5 Exit 1-8 Load 1-5 New 1-4 Open... 1-4 Preferences 1-7 Print 1-7 Save 1-5 Save All 1-7 Save As 1-6 Finding and Replacing Text 2-24 Finding Text 2-23, 2-52 Font Dialog Box 2-26

L
Load Dialog Box 2-20 Loading a Script File 2-19

M
Menu Bar 1-4 Microhelp 1-14 Multiple Connections 2-15 Multiple Text Result Windows 1-19

N
Navigating Script Windows 2-21

G
Grid Output Mode 1-21

O
Open Dialog Box 2-18 Opening a Script File 2-17 Opening Result Files 2-46 Overview 1-1

H
Help Menu 1-13 About SQL Advantage... 1-13 Contents 1-13 How to Use Help 1-13 Search for Help on... 1-13 Technical Support 1-13 History 2-44 History Dialog Box 2-45 History Recording Automatic 2-45 Index-2

P
Page Setup 1-8 Page Setup Dialog Box 2-34 Password Encryption 2-14 Pasting Text 2-22

SQL Advantage 11.0.x

Pick List Stored Procedures 2-39 System Procedures Syntax 2-42 Tables and Columns 2-36 T-SQL Commands Syntax 2-40 Views and Columns 2-38 Preferences Dialog Box Connection 2-7 Miscellaneous 2-10 Query 2-5 Result 2-8 Print Dialog Box 2-35 Printing 2-33 Page Footer 2-34 Page Header 2-34 Page Setup 2-33 Printing Results 2-52 Printing Scripts 2-35

Selecting Cells 2-48 Selecting Columns 2-50 Selecting Rows 2-49 Text Output Mode 1-19 Result Window Controls 1-19 Result Windows 1-18, 2-46 Editing in Text Output Mode 2-47 Printing 2-52 Saving Results 2-52 Selecting Rows 2-49

S
Save As Dialog Box 2-32 Saving Results 2-52 Saving Scripts 2-32 Script Windows Changing Fonts 2-26 Clearing Text 2-22 Finding Text 2-23 Navigating 2-21 Selecting Cells 2-48 Selecting Columns 2-50 Selecting Rows 2-49 Selecting Text 2-22 Server Menu 1-11 Connect 1-11 Disconnect 1-11 Session Maximize Control 1-17 Session Window 2-16 Changing Database 2-21 Changing Fonts 2-26 Clearing Text 2-22 Control Menu 1-16 Copying Text 2-22 Cutting Text 2-22 Editing Scripts 2-21 Executing Batch Scripts 2-27 Executing Scripts 2-27 Executing Selected Text 2-28 Executing Stored Procedures 2-29 Finding and Replacing Text 2-24 Finding Text 2-23 Joins 2-43

Q
Query Menu 1-11 Cancel Execution 1-12 Execute Query 1-11 Execute Selection 1-11 Execute Stored Procedure... 1-12 History 1-12 Joins 1-12

R
Recalling a Previous Query 2-44 Result Window Copying Columns 2-51 Copying Rows 2-50 Editing in Grid Output Mode 2-47 Finding Text 2-52 Grid Output 1-22 Grid Output Mode 1-21 Multiple Window Text Output 1-20 Navigating in Grid Output Mode 2-48 Resizing Columns 2-51 Resizing Rows 2-50

SQL Advantage Users Guide

Index-3

SQL Advantage 11.0.x

Loading a Script File 2-19 Maximize Control 1-17 Minimize Control 1-17 Opening a Script File 2-17 Pasting Text 2-22 Printing 2-33 Printing Scripts 2-35 Replacing Text 2-24 Restore Control 1-17 Saving Scripts 2-32 Selecting Text 2-22 Status Bar 1-17 Session Window Control Menu Close 1-16 Maximize 1-16 Minimize 1-16 Move 1-16 Next 1-17 Restore 1-16 Size 1-16 Setting Connection Preferences 2-6 Setting Miscellaneous Preferences 2-10 Setting Preferences 2-3 Setting Query Preferences 2-4 Setting Result Preferences 2-7 Single Text Result Window 1-20 SQL Advantage Application Window 1-1, 1-2 Starting from Windows Run Dialog Box 2-2 Starting SQL Advantage 2-1 Starting SQL Advantage on Windows 95 2-2 from Command Line 2-3 from Icon 2-2 from Start Menu 2-2 Starting SQL Advantage on Windows NT 3.51 2-1 from an Icon 2-1 from Command Line 2-1 Stored Procedures 2-29 Stored Procedures Pick List 2-39 System Procedures Syntax Pick List 2-42

System Procedures Syntax pick list 2-42

T
Tables and Columns Pick List 2-36 Technical Support 1-13 Text Output Mode 1-19 Tool Bar 1-13 Toolbar Cancel Execution 1-15 Change Database 1-15 Copy 1-15 Cut 1-15 Execute 1-15 Find 1-15 New 1-14 Open 1-14 Paste 1-15 Preferences 1-15 Print 1-14 Save 1-14 Undo 1-15 T-SQL Syntax Pick List 2-40

U
Undo 2-23 Using Query Construction Tools 2-36 Using Result Windows 2-46 Using Session Windows 2-16 Using SQL Advantage 2-1 Using System Procedures Syntax Pick List 2-42 Using the Stored Procedures Pick List 2-39 Using the Tables and Columns Pick List 2-36 Using the Views and Columns Pick List 2-38 Using T-SQL Commands Syntax Pick List 2-40

Index-4

SQL Advantage 11.0.x

V
View Menu 1-9 Edit Cell 1-9 Pick Lists 1-10 System Procedures Syntax 1-10 Tables & Columns 1-10 T-SQL Commands Syntax 1-10 Views & Columns 1-10 Refresh Lists 1-10 Status bar 1-9 Tool bar 1-9 Views and Columns Pick List 2-38

W
Window Menu 1-12 Cascade 1-12 Open Windows List 1-13 Tile 1-13

SQL Advantage Users Guide

Index-5

SQL Advantage 11.0.x

Index-6

You might also like