devxlogo

Passing a Parameter to a Stored Procedure

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

See also  Professionalism Starts in Your Inbox: Keys to Presenting Your Best Self in Email
devxblackblue

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