Executing Stored Procedures
To execute a stored procedure, you simply invoke it by using its name (the same way you probably have already executed system stored procedures, such as sp_help
). If the execution of the stored procedure isn’t the first statement in a batch, you need to precede the procedure name with the EXEC
keyword. Following is the basic syntax for executing stored procedures:
Note
The reason you need the EXEC
keyword when invoking a stored procedure in a batch or other stored procedure is quite simple. SQL Server parses the commands sent to it in a batch by searching for keywords. Stored procedure names aren’t keywords. If SQL ...
Get Microsoft® SQL Server 2008 R2 Unleashed now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.