Passing a Parameter to a Stored Procedure

Question:
How do you pass a parameter to a stored procedure from within another stored procedure?

Answer:
To call a stored procedure from inside another stored procedure, let’s take an example of a procedure that returns information for all the tables in a database or for a single table. The following stored procedure calls the sp_tables system stored procedure using the EXECUTE statement and takes either no parameters or the name of a table:

CREATE PROCEDURE ListTables  @TableName varchar(255)=NULL AS  SET NOCOUNT ON  EXEC sp_tables @TableName  RETURN 0GO

Share the Post:
Share on facebook
Share on twitter
Share on linkedin

Overview

Recent Articles: