Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 stored procedure from another and concantenate

Author  Topic 

magmo
Aged Yak Warrior

558 Posts

Posted - 2010-02-21 : 03:07:13
Hi

I have the need to execute another stored procedure/view from within an exsisting stored procedure, and I need to pass on 3 parameters to that stored procedure. Lets say I return a result from stored procedure 1 like this..

Model SectionID PartNumber OrderRow
1 22 111-22 10
1 22 222-33 20


Here I want to pass "model","SectionID" and "OrderRow" to another stored procedure. But here is another problem, that stored procedure can return multiple rows and I want thoose rows as one single result. So if stored procedure number 2 return a result like this...

ID Notes
1 first note
2 second note

I only want one row as result that contains both rows concantenated.

Can someone show how to do this, if possible at all?

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-02-21 : 03:20:30
its quite difficult to pass result from one stored procedure to another. either you've to put result to temporary table and then take it or use OPENROWSET as show below

http://sqlblogcasts.com/blogs/madhivanan/archive/2007/11/26/select-columns-from-exec-procedure-name-is-this-possible.aspx

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-02-21 : 03:21:15
b/w is it possible to turn one of procedure or both to udfs?

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2010-02-21 : 03:56:58
[You posted in SQL 2005 forum but:] in SQL 2008 you could pass an @TableVar (as a parameter) to the second Sproc - i.e. in Sproc1 store results into @TableVar and then pass that as Param to SProc2
Go to Top of Page

magmo
Aged Yak Warrior

558 Posts

Posted - 2010-02-21 : 04:18:34
Ok, I guess I can solve on the client instead, thanks for the replies
Go to Top of Page
   

- Advertisement -