Automatically Fixing Issues
Published 29 October 2019
As an extension to Code Analysis, SQL Prompt allows you to automatically fix certain issues that are present in your code.
Currently, SQL Prompt supports the automatic fixing of the following issues:
- BP002: ORDER BY clause with constants
- BP005: Asterisk in SELECT list
- BP006: TOP without ORDER BY
- BP012: CASE without ELSE
- BP014: [NOT] NULL option is not specified in CREATE/DECLARE TABLE statement
- BP022: Money/SmallMoney datatype is used
- MI005: Variable is declared but never used
- PE006: Table hint is used
- SC006: The EOL marker sequence is not the expected CR/LF
- ST003: Enclose procedure body with BEGIN/END
- ST006: Old style TOP clause is used
- ST008: Non-named parameter style used
- ST013: Non-ANSI NOT_EQUAL operator used (!=)
When you left-click an issue present within your code, a light bulb icon will appear in the sidebar:
are automatically fixable
Issues that cannot be fixed automatically
When you click on the light bulb, a menu appears that allows you to apply a fix (when applicable), show more details about the issue, or see a list of all issues in the script.
Note that some fixes will require you to enter additional information. For example, after applying the fix for issue BP006: TOP without ORDER BY, you will need to type the name of the column or expression that you want to use to sort your results.