O'Reilly logo

Microsoft® SQL Server® 2008 Step by Step by Mike Hotek

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

You access a stored procedure by using an EXEC statement. If a stored procedure does not have any input parameters, the only code required is:

EXEC <stored procedure>

If a stored procedure has input parameters, you can pass in the parameters either by name or by position.

--Execute by name
EXEC <stored procedure> @parm1=<value>, @parm2=<value>,. . .
--Execute by position
EXEC <stored procedure> <value>, <value>,. . .

Executing a stored procedure by position results in code that is more compact; however, it is more prone to errors. If the order of the parameters in a procedure is changed, your code will not be affected if you are executing a procedure and passing the parameters by name.

In order to utilize an output parameter, ...

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