gamaz2
Starting Member
31 Posts |
Posted - 2008-12-14 : 02:03:20
|
Hi,I have a stored procedure as follows:alter procedure prr_temp_source_partnum_out @part_num varchar(50)--,@projectno varchar(11) outputasBEGIN SET NOCOUNT ON --Make a temporary table--Make a temporary table that extracts partnumber in one column in accordance with the rule set by Gregcreate table #temp1a(projectno varchar(11),partnumber varchar(50))insert into #temp1aselectprojectno,case when overridepart = 0then tblprrin.partnumberprselse tblprrin.partnumberprrend as partnumberfrom tblprrinselect * from #temp1a where partnumber = @part_num/*set @projectno = (select projectnofrom #temp1awhere partnumber = @part_numgroup by projectno)select @part_num*/ENDGONow when I pass the part_num 'E360MLID' to the stored procedure I get the following output projectno partno08-03520-00 E360MLID08-03267-01 E360MLID06-10595-03 E360MLIDNow I need to utilize this data set to another stored procedure which is as follows:CREATE procedure prr_temp_source_out_utilizing_part_num @project_num varchar(11), -- ,@plant varchar(11)@part_num varchar(30)asBEGIN SET NOCOUNT ON --Make a temporary tablecreate table #temp1( project_num varchar(11), project_desc ntext, eng_id varchar(11), last_name varchar(30), first_name varchar(30), tc_num smallint, tc_loc varchar(30), plantid varchar(11))insert into #temp1SELECT PRS.dbo.Project.Project_Num, PRS.dbo.Project.Project_Desc, PRS.dbo.Project.Eng_ID, PRS.dbo.Users.Last_Name, PRS.dbo.Users.First_Name, PRS.dbo.Users.TC_Num, PRS.dbo.Tech_Centers.TC_Loc, PRS.dbo.tblCostPlants.PlantID FROM PRS.dbo.Project INNER JOIN PRS.dbo.Users ON PRS.dbo.Project.Eng_ID = PRS.dbo.Users.User_ID INNER JOIN PRS.dbo.Tech_Centers ON PRS.dbo.Users.TC_Num = PRS.dbo.Tech_Centers.TC_Num LEFT JOIN PRS.dbo.tblCostPlants ON PRS.dbo.Project.Project_Num = PRS.dbo.tblCostPlants.Project_num--select * into temp1 from #temp1 --select * from #temp1create table #temp2( project_num varchar(11), project_num_trun varchar(8), project_desc ntext, eng_id varchar(11), last_name varchar(30), first_name varchar(30), tc_num smallint, tc_loc varchar(30), plantid varchar(11), plant_desc varchar(20))-- select * from #temp2insert into #temp2SELECT Project_Num, (Left([project_num],8)) AS project_num_trun, Project_Desc, Eng_ID, Last_Name, First_Name, TC_Num , TC_Loc, PlantID, Plant_Desc FROM dbo.#temp1 LEFT JOIN PRS.dbo.Plants ON dbo.#temp1.PlantID = PRS.dbo.Plants.Plant --where #temp2.project_num = @project_num--select * from #temp2--where project_num = @project_numcreate table #temp3( project_num varchar(11),project_desc ntext,part_num varchar(20),engineer varchar(60),plant varchar(20))insert into #temp3SELECT dbo.#temp2.Project_Num--, project_num_trun, Project_Desc, PRS.dbo.tblSoldInfo.part_num--, Eng_ID--, Last_Name--, First_Name, Engineer = (last_name + ',' + first_name)--, TC_Num--, TC_Loc--, PlantID, plant = Plant_DescFROM dbo.#temp2 LEFT JOIN PRS.dbo.tblSoldInfo ON dbo.#temp2.project_num_trun = PRS.dbo.tblSoldInfo.project_numwhere dbo.#temp2.project_num = @project_num-- select * from #temp3--where project_num = @project_num--where plant = @plant--select overridepart from tblprrin where projectno = @project_numcreate table #temp4(prr_id int, project_num varchar(11),project_desc ntext,engineer varchar(60),plant varchar(20),part_num varchar(20),prr_in_added_date datetime,poduedate datetime)insert into #temp4select tblprrin.prr_id, #temp3.project_num,#temp3.project_desc,#temp3.engineer,#temp3.plant,case when overridepart = 0then tblprrin.partnumberprselse tblprrin.partnumberprrend as partnumber,tblprrin.prr_in_added_date,tblprrin.poduedatefrom #temp3 inner jointblprrin on tblprrin.projectno = #temp3.project_num and--tblprrin.plantprs = #temp3.plant(tblprrin.plantprs = #temp3.plant OR #temp3.plant IS NULL)where tblprrin.partnumberprs is not null select * from #temp4 where part_num = @part_num--where plant =@plant/*select tblPrrIn.prr_id, tblPrrIn.needupdate, #temp4.project_num, #temp4.project_desc, #temp4.part_num, #temp4.engineer, #temp4.plant, #temp4.prr_in_added_date, #temp4.poduedatefrom tblPrrIn inner join#temp4 On tblPrrIn.projectno = #temp4.project_numWHERE tblPrrIn.Prr_In_added_date = #temp4.Prr_In_added_date*/ENDThe thing is I need to use each of the rows (obtained from the first stored procedure result) as parameters to the second stored procedure. If I use each of this row as parameter separately I get three separate output. However I need get the three output as a dataset (instead of three separate data set) . I am not getting much clue as how to achive this. Any help is highly appreciated. Thanks in advance. |
|