How do i pass a table variable or temp table as a input paramenter to a stored procedure????? HELP!
I have a select that returns one column with multiple rows which i will populate into a temp table. But then i need to pass that temp table to another stored procedure. Please explain with sample code as to how to do this.
Status:
Open Feb 12, 2009 - 12:55 AM
SQL SERVER 2005, .net
2answers
Answers
Mar 26, 2009 - 03:14 AM
You can do that by using #temp_table which will be accessible throw the called store procedures and functions for current session. Note: will be better to drop the table at the end of your work.
example using Northwind DB:
CREATE PROCEDURE Test_GetTempData
-- Add the parameters for the stored procedure here
AS
BEGIN
Select * from #temp_Table
END
CREATE TABLE #temp_Table(
[CustomerID] nchar(5) ,
[CompanyName] nvarchar(40)
)
insert into #temp_Table(CustomerID, CompanyName)
select [CustomerID], [CompanyName] from customers
EXEC[dbo].[Test_GetTempData]
drop table #temp_Table
Apr 17, 2009 - 06:25 AM
The question looks to be abandoned by the user who asked it. If no action is taken within 2 days, a Quomon Moderator will consider closing the question and distributing the points.
The Quomon Team
Answer this question
Share Your Own Experience & Expertise
We look to ensure that every question is answered by the best people with relevant expertise and experience, the best answers include multiple perspectives. Do you have relevant expertise or experience to contribute your answer to any of these commonly asked questions?
Add New Comment