Encapsulate as SP_ExecuteSQL Call
The Encapsulate as SP_ExecuteSQL Call command converts the selected code into a call to the sp_executesql stored procedure.
This topic contains the following sections:
The Encapusulate as SP_ExecuteSQL Call command modifies the source script and wraps the selected code as a call to the sys.sp_executesql stored procedure.
To encapsulate the selected code:
1. Select the script that you want to encapsulate.
2. On the SQL Enlight->Refactor menu, click Encapusulate as SP_ExecuteSQL Call .
3. The Encapsulate as SP_ExecuteSQL Call dialog box is displayed.The resulting SQL script for is displayed in the Preview box.
4. Modify the order, the type and the direction of the parameters using the Parameters grid.
5. Review the generated script in the Preview box and modify it if necessary.
6. Click Apply button to apply the changes.
The parameters of the new objects are determined from the variables which are referenced in the selected code.
SQL Enlight automatically resolves the data type and the direction of these parameters. If a variable is used, but declared nowhere in the script, its declaration in the resulting script will have sql_variant data type.