O'Reilly logo

Microsoft® SQL Server 2012 Unleashed by Alex T. Silverstein, Chris Gallelli, Paul T. Bertucci, Ray Rankins

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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:

[EXEC[UTE]] [@status =] [schema].procedure_name[; number]  [[@param_name =] expression [output][, ... ]][WITH RECOMPILE    | { RESULT SETS UNDEFINED }    | { RESULT SETS NONE }    | { RESULT SETS ( <result_sets_definition> [,...n ] ) }]

Note

The reason you need the EXEC keyword when invoking a stored procedure in a batch or ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required