SQL Editor for ad-hoc SQL Anywhere and SAP ASE queries

In this post I’ll introduce you to the SQL editor. The SQL editor is a place for you to write  and execute ad-hoc SQL.

SQL Editor for ad-hoc SQL Anywhere and SAP ASE queries
SQL Editor for ad-hoc SQL Anywhere and SAP ASE queries

Syntax Folding

By default, syntax folding is enabled. “Fold” icons and lines are visible in the margin closest to the editor text (to the right of the line number margin). The editor will attempt to match up start and end statements in your script to create code blocks. These code blocks can be collapsed or expanded when clicking the + or – icons. To disable syntax folding, go to the Editor section in the Options window and un-check “Syntax Folding”.

SQL Auto Complete

Script auto complete is meant to assist you as you type your query. Database objects, including table columns will display in a pop for easy selection. Auto complete is triggered in a number of different ways.

  • Typing a database owner followed by a period (e.g. dba. or dbo.).
  • Entering a space after typing FROM or JOIN.
  • Typing a table alias followed by a period.
  • Hitting the Ctrl+Space keys.
  • Typing in the averSQL keyword “this”:
    • This keyword is configurable in the Options window under the “Auto Complete” section. The option is called Autocomplete Tag. You can use any word you like.
    • The auto complete popup that displays using this method will display “my autocomplete” items, database owners,  and database (for ASE).
    • My Autocomplete will be covered in another post. Essentially, it gives you a way to create custom auto complete lists.

Go to Definition

Do you have a database object referenced in your script and you would like to see the “CREATE Statement” for it? Right click on the object name and select Go To Definition from the pop menu. Or place your cursor in the object name and press the F4 keyboard shortcut. The script for the object will instantly open in a new editor window.

Column Lists

To quickly view a list of columns for a table referenced in the sql editor, place you cursor in the table name and press the F2 keyboard shortcut. A new popup window will display showing all the columns in that table. You can leave this window open, drag it around, and resize it. You have many of these popup windows open at the same time as well. To add columns to your editor, drag from the popup or select one or more columns and click the Add button. If you use the Add button, columns will be added to where ever the cursor currently is in you editor.

As an additional bonus, this feature also works for stored procedure parameters.

Options

There are many different options to customize the editor. Go to the Options window under the Tools menu and select Editor. For more details about each option, visit the averSQL help file.