September 8, 2008 at 2:13 pm
I have a stored procedure and with in the stored procedure I have multiple select statements. When I execute the sp, I get multiple results. I would like to combine these results into one.
The first query gets the info. The second query returns a value based on an if statement. The third query returns multiple row records into one column. I probably can't post my sql, so that is why i'm giving a description of my queries.
September 8, 2008 at 2:41 pm
Hello bdavis,
You might be able to do a UNION. You can look up the topic in BOL.
Do the queries return the same columns?
Best Regards,
Chris Büttner
September 8, 2008 at 3:23 pm
probably can't post my sql, so that is why i'm giving a description of my queries.
Extremely difficult to make any meaningfully suggestions with such meager information. Can you dummy up your T-SQL using false table / column names. Brief table constructs which will illustrate what you want to do without revealing any confidential information?
September 8, 2008 at 3:54 pm
bdavis (9/8/2008)
I have a stored procedure and with in the stored procedure I have multiple select statements. When I execute the sp, I get multiple results. I would like to combine these results into one.The first query gets the info. The second query returns a value based on an if statement. The third query returns multiple row records into one column. I probably can't post my sql, so that is why i'm giving a description of my queries.
You can try converting the second and third queries to output parameters instead of resultsets. Here is an example:
CREATE PROCEDURE #Procedure
@RunDate datetime output
,@parm_2 varchar(20) output
AS
SET @RunDate = getdate();
SET @parm_2 = 'This is parm 2';
GO
DECLARE @RunDate datetime;
DECLARE @parm_2 varchar(20);
EXECUTE #Procedure @RunDate OUTPUT, @parm_2 OUTPUT;
SELECT @RunDate, @parm_2;
GO
Jeffrey Williams
“We are all faced with a series of great opportunities brilliantly disguised as impossible situations.”
― Charles R. Swindoll
How to post questions to get better answers faster
Managing Transaction Logs
September 9, 2008 at 4:25 am
plz provide the dummy script...:cool:
-------Bhuvnesh----------
I work only to learn Sql Server...though my company pays me for getting their stuff done;-)
September 9, 2008 at 5:38 am
Hi bdavis,
Please describe what do u want to do through these multiple select setements ? do u want to use results (from these statement)
as a single record set?
please make it clear?
:Whistling:
September 9, 2008 at 7:17 am
Jeffrey Williams (9/8/2008)
bdavis (9/8/2008)
I have a stored procedure and with in the stored procedure I have multiple select statements. When I execute the sp, I get multiple results. I would like to combine these results into one.The first query gets the info. The second query returns a value based on an if statement. The third query returns multiple row records into one column. I probably can't post my sql, so that is why i'm giving a description of my queries.
You can try converting the second and third queries to output parameters instead of resultsets. Here is an example:
CREATE PROCEDURE #Procedure
@RunDate datetime output
,@parm_2 varchar(20) output
AS
SET @RunDate = getdate();
SET @parm_2 = 'This is parm 2';
GO
DECLARE @RunDate datetime;
DECLARE @parm_2 varchar(20);
EXECUTE #Procedure @RunDate OUTPUT, @parm_2 OUTPUT;
SELECT @RunDate, @parm_2;
GO
Jeff, I did what you said and it worked perfectly. thanks a bunch for your help.
September 9, 2008 at 2:15 pm
Glad I could help
Jeffrey Williams
“We are all faced with a series of great opportunities brilliantly disguised as impossible situations.”
― Charles R. Swindoll
How to post questions to get better answers faster
Managing Transaction Logs
Viewing 8 posts - 1 through 7 (of 7 total)
You must be logged in to reply to this topic. Login to reply