SQL Complete incorporates a built-in Command Line Wizard that allows users to convert their options, such as searching for invalid objects or code formatting, into command-line syntax and save them as *.bat files.
This feature can be used for scheduling or automating the search for invalid objects in multiple databases. You can then use a *.bat file containing a script along with Windows Task Scheduler or any other task scheduler tool to automate the process of searching for invalid objects.
You can select command-line file settings to manage *.bat file text in the Command line execution file settings window. You can open the window by clicking Save Command Line in:
The command line wizard has the following options:
Option | Description |
---|---|
Connection | Specify the connection string of the database to search for invalid objects. |
Password | Specify the server password. Note that it will override the values specified in the Connection parameter. |
Database | Specify the database to find invalid objects. You can specify either a single database or multiple databases separated by commas. Note that it will override the database specified in the Connection parameter. |
All databases | Select this option if you want to search for invalid objects in all non-system databases located on the server. |
Report | Specify a path to the report that will be generated in the CSV file format. |
Log | Specify a path to a log file. |
Echo OFF | Select this option to enclose all the text in the bat file in the @Echo OFF … @Echo ON construct. This will turn off the display of the commands entered on the screen. |
Keep opened | Select this option to place the pause command at the end of the bat file text. This will leave the command window open. |
PowerShell | Select this option to generate the & symbol at the beginning of the bat file text. This will ensure the PowerShell compatibility. |
The command line wizard has the following options:
Option | Description |
---|---|
Connection | Specify the connection string. |
Password | Specify the server password. It overrides the password specified in the connection string. |
Profile | Specify the path to the file that contains formatting options settings or a predefined profile name. If the parameter is not specified, default formatting options settings will be applied. |
Encoding | Specify the encoding that should be applied to open and save files. |
Source File | Specify the source SQL file to be formatted. |
Output File | Specify the path to an output file where the formatting results of the source file will be saved (in this case, the source file is saved without changes). If the parameter is not specified, the formatting results will be saved in the source file. |
Log file | Specify the path to the formatting log file. |
Echo OFF | Select this option to enclose all the text in the bat file in the @Echo OFF … @Echo ON construct. This will turn off the display of the commands entered on the screen. |
Keep opened | Select this option to place the pause command at the end of the bat file text. This will leave the command window open. |
PowerShell | Select this option to generate the & symbol at the beginning of the bat file text. This will ensure the PowerShell compatibility. |
After setting the required options for the potential script, you can click Validate to check the accuracy of the code.
If the syntax is valid, you will receive the following message:
Otherwise, the corresponding warning will be displayed:
After validating the code, you can save the script as a *.bat file by clicking Save and specifying a path to its location.