How to ... Open and save queries

You can open an existing query from any file location using the Open Query toolbar and menu commands.

When the Workspace Open Query toolbar button is used the query will be opened against the selected workspace database (or the database the selected object is within).

When opening a query using the main toolbar button from an open query window the query will be opened against the same database as that used by the open query. If no query window is available a dialog is displayed allowing you to select the server and database you would like to connect to.

Opening a query from the File menu always prompts for the server and database to connect to.

As an alternative to opening the query within SQL Visualizer, you can also drag and drop files from Windows Explorer. Drag the file from Windows Explorer over an open query window to open the query against the same database as the open query. Alternatively you can drag a file over a database node in the Workspace to open it against that database.

A useful addition to the drag and drop functionality is to drag multiple files holding down the Ctrl key when dropping. These files will be opened in a single query window, each enclosed in a collapsible region. You can then execute all the queries as a single operation rather than opening and executing each one separately.

When a query is opened the Workspace synchronizes with the database the query is opened against. You can turn this feature off in the Tools-Options dialog (see Changing options and preferences for more details).

To save a query simply click the Save Query toolbar button or select Save from the File menu. If a query is new and has yet to be saved then you will be prompted to select the name and location to save the file to.

If you have multiple unsaved queries you can use Save All from the toolbar or from the File menu to save all edited files in one go.