WiseOwl Training - Established 1992 Wise Owl Training

Established May 1992
30 years in business
Wise Owl Training
30 years in business
See 519 reviews for our classroom and online training
SQL stored procedures and passing parameters
Part three of a six-part series of blogs

Stored procedures are programs in SQL which allow you to pass parameters to queries and manipulate sets of rows in tables. Find out how to write them with this online training blog!

  1. Stored Procedures in SQL
  2. Creating Simple Stored Procedures
  3. Running Stored Procedures (this blog)
  4. Modifying or Changing a Stored Procedure
  5. Passing Parameters to Stored Procedures
  6. A Worked Example of a Longer Stored Procedure

This blog is part of a complete SQL Server tutorial, and is also referenced from our ASP.NET online training blog.

Posted by Andy Brown on 24 May 2012

You need a minimum screen resolution of about 700 pixels width to see our blogs. This is because they contain diagrams and tables which would not be viewable easily on a mobile phone or small laptop. Please use a larger tablet, notebook or desktop computer, or change your screen resolution settings.

Running Stored Procedures

Let's suppose that you've created the stored procedure described in the previous part of this blog:

CREATE PROC spListActors


-- display list of actors






You now want to run the spListActors stored procedure, to list out its contents.  Below are 3 ways to do this.

Methood 1 - Selecting the Stored Procedure Name

The simplest way to run a stored procedure is just to select its name and press F5:

Running stored procedure

Just double-click on the name of the stored procedure to select it, and then execute it like any other SQL query.


This will produce the results of the SELECT statement included in the procedure:

Results of procedure

The first few rows returned by running the procedure.


Note that this method doesn't work if your stored procedure takes parameters (then again, we haven't covered parameters yet!).

Method 2 - Right-Clicking on the Procedure Name

A second way to run a stored procedure is to right-click on its name:

Executing stored procedure

Right-click on the name of the procedure in SQL Server Management Studio and choose to execute it as shown here.


Again, this method doesn't work well if your stored procedure takes parameters.

Method 3 - Execute the Stored Procedure in a Query

The third way to run a stored procedure is to use the EXECUTE command within a query:

-- 3 ways to run procedure to list out actors

EXEC spListActors


EXECUTE spListActors




As the above examples show, you can abbreviate EXECUTE to EXEC or - under certain circumstances - miss it out altogether.

This blog has 0 threads Add post