BP013

EXECUTE('SQL script') is used

EXECUTE('SQL script') is being used to execute a SQL batch in a string.

Avoid using EXEC to run dynamic SQL. EXEC is retained for backward compatibility and can be used for SQL injection. Use sp_executesql instead: it allows parameter substitutions for both inputs and outputs and also because the execution plan that sp_executesql produces is more likely to be reused.


This documentation contains proprietary information and is protected by copyright law.
Copyright © 2026 Red Gate Software Limited. All rights reserved


Didn't find what you were looking for?