Passing a Parameter to a Stored Procedure

Passing a Parameter to a Stored Procedure

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

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

See also  How College Students Can Shape the Future of Tech Responsibility

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist