Published 12 April 2021
Formatting
Redgate SQL Prompt Core is only available in Visual Studio Enterprise 2017. For other versions of Visual Studio, and for new features and support, upgrade to SQL Prompt Pro. SQL Prompt Core is a free extension for Visual Studio Enterprise, which improves your productivity with advanced IntelliSense-style SQL code completion. SQL Prompt code analysis, introduced in v9.2, provides a quick and easy way to assess the overall health and quality of your SQL scripts. It will help the team prevent technical debt from entering the code base, to remove it from existing code during code reviews, and to ensure that the released code conforms to the team's defined coding standards.
SQL Prompt ships with a formatter that can be run from the command line to format a collection of SQL files.
Where to find the command line formatter
The command line formatter can be found inside a zip file called FormatCommandLine.zip in the SQL Prompt installation directory (usually C:Program Files (x86)Red GateSQL Prompt 10).
To run the command line formatter, extract the zip file to a directory and run SqlPrompt.Format.CommandLine.exe with the desired arguments.
Adding the command line formatter to your PATH variable
To make the command line formatter accessible within a command prompt (e.g. Windows Terminal) without specifying its full path, you can add the formatter to your PATH environment variable:
- Search path in the start menu, and click on Edit environment variables for your account:
- Click on Environment Variables, then double click on the entry titled Path. Then press New and add the path of the folder you have extracted the command line formatter to:
- You should then be able to use SqlPrompt.Format.CommandLine.exe directly within your command prompt window.
Running the command line formatter
To run the SQL Prompt formatter from the command line, run SqlPrompt.Format.CommandLine.exe with the relevant arguments:
Option | Alias | Description |
---|---|---|
--i-agree-to-the-eula | Confirms that you agree to the End User Licence Agreement when running the command line formatter. This argument is required. | |
--path | -p | The file or directory to format. This argument is required. |
--create-backups | -b | Create backups of formatted files. The original SQL file will be backed up to a file with a .bak extension, located next to the original file. |
--style | -s | The name of a Redgate formatting style, or the file path of a formatting style file (.json). If no style is specified, laying out of SQL will be skipped. The name of the Redgate formatting style can be one of:
|
--apply-casing | -ac | Apply casing options when formatting. The options are defined in the Global → Casing section of a formatting style. |
--prefix-unicode | -n | Prefix N to unicode literal string variable assignments. |
--insert-semicolons | -is | Insert semicolons. |
--enclose-identifiers | -e | Add/remove square brackets. Possible values:
|
--table-alias-style | -ta | Add/remove AS keyword on alias definitions for tables and views. Possible values:
|
--column-alias-style | -ca | Apply column alias style. Possible values:
|
--version | Shows the current version number of the command line formatter. | |
--help | -h, -? | Shows the command line help that lists the available options. |
Omitting any argument will cause that formatting action to be skipped.
When running, the command line formatter will summarize the options that it is using to apply the format:
As it processes each SQL file to be formatter, the command line formatter will show progress and any errors encountered:
Didn't find what you were looking for?
SQL Prompt stores information about the structure of databases in cache files. SQL Prompt creates a cache file for each database that you use. The cache files are encrypted and stored in your local settings on your computer; SQL Prompt can read only the files that were created by your Windows® user.
Note that SQL Prompt does not create cache files for databases you have chosen to ignore.
If the structure of the databases has been modified, for example if a table has been added to the database, you can refresh the cache files so that the changes are shown in the candidate list. You can refresh the cache file for selected databases or refresh all the SQL Prompt cache files; SQL Prompt updates the cache files ready for you to use immediately. Note that if a database is being restored or it is offline, you cannot refresh its cache file.
You can also delete cache files, for example to create disk space. You can delete the cache file for selected databases or delete all the SQL Prompt cache files; SQL Prompt creates new cache files the next time you use the databases in your query editor.
To refresh or delete cache files, on the SQL Prompt menu in your query editor, click Cache Management.
Note that you can set SQL Prompt so that it refreshes cache files when you start your query editor and you connect to a database for the first time. You do this by selecting the Refresh the cache automatically check box.
Refreshing cache files
To refresh all the cache files:
- Click Refresh All.
The Caching Progress bar shows the progress of the refresh.
- Click Close to close the SQL Prompt Cache Management dialog box.
To refresh selected cache files:
- Select the required database(s).
You can select multiple databases using SHIFT+Click or CTRL+Click.
- Click Refresh.
The Caching Progress bar shows the progress of the refresh.
- Click Close to close the SQL Prompt Cache Management dialog box.
Deleting cache files
Redgate Sql Prompt Pro
To delete all the cache files:
Redgate Sql Prompt Styles
- Click Delete All.
SQL Prompt deletes all the cache files.
- Click Close to close the SQL Prompt Cache Management dialog box.
To delete cache files:
- Select the required database(s).
You can select multiple databases using SHIFT+Click or CTRL+Click.
- Click Delete.
SQL Prompt deletes the cache files for the selected database(s).
- Click Close to close the SQL Prompt Cache Management dialog box.
Redgate Sql Prompt Price © Red Gate Software Ltd 2007. All Rights Reserved. |