Handling Results
  
Handling Results
By default when a sql statement is issued the results appear in the results pane. It is, however, possible to redirect these results to the edit pane, a file or some combination of the three main output options.
It is not possible to print the results from the Sql Admin tool. To print the results you must either save the results to file and then print that file or send the results to Windows Excel and print from within Excel. See the following sections on how to perform these functions.
 
 
Results Output to File
To send the output of a sql statement to a file select the menu option Sql/Out -> File Only or the menu option Sql/Out -> File + List. When either menu option is selected a 'Save As' dialog will appear to allow the specification of a directory and file name for the file. The second menu option will put the output to both the file and the results pane. This may be slow if a large amount of data is retrieved.
When either of the above menu options is selected a tick will appear next to the menu option to indicate the current data output method. This method stays in effect until changed by the selection of a different output option. The default option is 'Out -> List Only'.
The columns in the results are separated by a comma by default. This default setting can be overridden by selecting the Sql/Set File Delimiter menu option and changing the contents of the 'Column Delimiter in Output File' field to the desired delimiter. The delimiter may be multiple characters if desired.
Once the file name has been entered and a suitable delimiter chosen the sql statement can be issued. When all data is retrieved the file would normally be closed by selecting the Sql/Close File menu option. This option closes the file and reverts to the default output method of 'Out -> List Only'.
 
Results Output to Excel
The results of a query can be moved to the Windows Excel tool. To do so proceed as follows:
1 Issue the required sql statement displaying the results in the results pane.
2 Position the cursor in the results pane and using the right mouse menu select the menu option 'Excel it'. This will create or replace the file garth.xls in the QAD program directory. It will then invoke this file which in turn will invoke Windows Excel if it is associated with the file extension (.xls) and it is available on the PC.
3 Within Excel highlight the first column by clicking on the column header (normally 'A').
4 Again within Excel select the 'Data/Text to Columns...' menu option and answer the questions. Under normal conditions the data is comma delimited.
5 Save the Excel spreadsheet under a new name if you wish to retain it. The sheet will be overwritten the next time this procedure is undertaken if not saved under a new name.
 
Building Statements from Results
Sql Admin can be used to build up sql statements from the results of other sql statements. For example we may wish to grant access to all of our tables to a new user. We could do this by issuing a statement to list all the table names and use Sql Admin to build up the statements to perform the grants.