Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: SQL Server
Expertise: Beginner
Jun 20, 2000

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 0
GO
DevX Pro
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date