February 5, 2010 at 1:31 pm
I was wondering if I can contruct a stored procedure that can add a value to to resultset. In my case I would like to add the value 'ALL' Thanks for any help.
February 5, 2010 at 1:34 pm
Care to show us what you asking?
February 5, 2010 at 1:44 pm
Yes like i said I have a stored procedure that I execute to return a resultset. This resultset is simply to provide a list of states to the user.However there is a value that is not in the returned resultset that i need. For Example the value ALL.
February 5, 2010 at 1:52 pm
Try to use UNION or UNION ALL statement. (For details please see BOL or provide some more details on what you're trying to do).
February 5, 2010 at 1:55 pm
No, that isn't what I asked for. Show what you are trying to accomplish. What code have you written so far, and you actually want.
February 5, 2010 at 1:58 pm
Select * from States. Then I want to add the value ALL to the resultset.
February 5, 2010 at 2:02 pm
So it sounds like i would need to create a new table just to hold the value ALL?
February 5, 2010 at 2:04 pm
ronaldkrex (2/5/2010)
Select * from States. Then I want to add the value ALL to the resultset.
Not really sure if you want this:
select 'ALL',StateName from States
or this
select StateName from States
union all
select 'ALL'
Hard to tell as you haven't shown what you want.
February 5, 2010 at 2:23 pm
Thanks it worked great however I lost my column name. Can you tell me how to rename it from No column name to depatment.
February 5, 2010 at 2:32 pm
Show me your code.
February 5, 2010 at 2:39 pm
select 'ALL'
union all
SELECT distinct Department FROM dbo.tblReportData
February 5, 2010 at 2:46 pm
ronaldkrex (2/5/2010)
select 'ALL'union all
SELECT distinct Department FROM dbo.tblReportData
select 'ALL' as Department
union all
SELECT distinct Department FROM dbo.tblReportData
February 5, 2010 at 2:57 pm
I was just going to tell you I figure it out. You have Been very very helpful. Thank you so much. What do I do to vote for you or give you credit for answering my question?
February 5, 2010 at 4:19 pm
ronaldkrex (2/5/2010)
I was just going to tell you I figure it out. You have Been very very helpful. Thank you so much. What do I do to vote for you or give you credit for answering my question?
This web site doesn't work that way... we've evolved:w00t:
Wayne
Microsoft Certified Master: SQL Server 2008
Author - SQL Server T-SQL Recipes
Viewing 14 posts - 1 through 13 (of 13 total)
You must be logged in to reply to this topic. Login to reply