Code completion

Applies to

ApexSQL Complete

Summary

This article describes how to use ApexSQL Complete options to manage the auto-complete hint-list and use the auto-complete feature to speed up coding.

Description

To enable the Auto-complete feature, navigate to the ApexSQL Complete menu, and click the Enable auto-complete command:

ApexSQL Complete main menu

Once the feature is enabled each time the typing is started in the query window, the hint list appears, offering a hint to complete keyword, SQL fragment, or even entire SQL statement. Prior to the first appearance, the hint list loads SQL database objects based on one of the following:

The current database connection:

Current database connection

Database specified in the Use statement:

Loading the hint-list

Quick tip icon

Quick tip:

Since the add-in loads hints for the specified database just once (on the first hint list appearance), it is recommended to wait for the add-in to finish loading. After the hints are loaded, they will not be loaded again, until the host application is restarted

Hint list management

The hint list can be managed from the Options window, under the General tab, that can be initiated by going to ApexSQL menu -> ApexSQL Complete -> Options:

Hint list management

The hint list offers context sensitive hints, and provides possible solutions based on the content of the current query. As an example, if the Use statement is entered, the first hints in the hint list will be available databases from the server:

The hint-list offers object from a database

The hint list offers the dill down to the column level:

The hint list offers the dill down to the column level

Hint list transparency

In case where a quick overview of current SQL code is needed, when working with large scripts, hint list can be set as transparent, so the background SQL code will be available to explore. To invoke the hint list transparency, the CTRL key needs to be pressed:

Transparent hint-list

FAQ’s:

Q: How can I speed up the process of loading hints?

A: Cache loading speed depends on numbers of objects (hints) selected. To speed up loading, exclude unwanted hints from the Hints tab under the Options window.

Q: I have created a new object in the database, but how do I find it in the hint list?

A: Each time new object is created the cache needs to be refreshed, in order for ApexSQL Complete to detect newly created object, and offer it in the hint list. The default combination of keys to refresh cache is (Ctrl + Shift + Alt + I).

Q: What is a Schema cache?

A: The Schema cache is a list of objects that the add-in cached in order to show them in the hint list.

Q: Can I see a script of the specific object before choosing it from the hint list?

A: Yes. Right after the hint list appears, the object which script needs to be presented must be highlighted (using the arrow keys). After a second, the Object script box appears showing the T-SQL script for the selected object:

Object scripting

Q: Can I auto-complete closing characters such as parenthesis, quotation marks, etc.?

A: Yes. These auto-completions can be enabled from the Options window, in the Closing characters sections, under the Inserts tab:

Closing characters sections

Q: How can I invoke Linked server hints?

A: Check the Linked servers hints option in the Hints tab, under the Options window. When the option is checked, linked server should appear in the hint list:

Linked servers

Putting the dot after the auto-completed linked server hint will trigger the connection to the linked server. ApexSQL Complete tries to establish a connection using the Windows authentication if possible. If it fails to automatically connect to the Linked server (after about 20 seconds), popup window appears, offering the option for SQL authentication credentials:

Linked server dialog

When the credentials are specified, hints from the linked server will be available.

Q: Is there any way to format aliases, or to auto-complete them?

A: In the Inserts tab, under the Options window, there are options to auto-generate aliases, to add the AS keyword automatically with alias, and format it, additionally:

Inserts tab

Q: Why some hints at the top of the hint list are green?

A: ApexSQL Complete is aware of the content from the current query. This means that each object that has a Create statement, in the current query will be on a top of the hint list (no matter if an object is created or not):

Current query content