SELECT ... WHERE from a row set produced by a store procedure

How can I exclude, say, 'b' from a row set produced by
create  proc #_ as
      select 'a' a union
      select 'b' union
      select 'c'
go
?
I know, "use a function returning a table".
But is there an elegant way of manipulating with row set returned by a stored procedure. Backward compatibility plays its role here.
Thanks,

--Igor
LVL 1
midfdeAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

BrandonGalderisiCommented:
Well....
Insert into #Temp (Col1)
exec up_MyProc
 
select * from #temp where col1 <> 'b'

Open in new window

0
dqmqCommented:
You've oversimplified to the point you question does not make sense. Perhaps you can elaborate:

To eliminate 'b', there are several ways:

create  proc #_ as
      select 'a' a union
 --     select 'b' union
      select 'c'
go


OR


create  proc #_ as

Select * from (
      select 'a' a union
      select 'b' union
      select 'c'
     ) where a <> 'b'
go

Surely, I'm missing the essence of  your question
0
midfdeAuthor Commented:
Invalid object name '#Temp'.
0
10 Tips to Protect Your Business from Ransomware

Did you know that ransomware is the most widespread, destructive malware in the world today? It accounts for 39% of all security breaches, with ransomware gangsters projected to make $11.5B in profits from online extortion by 2019.

BrandonGalderisiCommented:
You would have to create the table #Temp in order to select the records.  I was assuming that your stored procedure returned more than 'a', 'b', 'c' so it was just an example.
Create table #Temp (Col1 varchar(255), col2 varchar(255))
Insert into #Temp (Col1)
exec up_MyProc
 
select * from #temp where col1 <> 'b'

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
midfdeAuthor Commented:
Great! Thanks.  I did not know that INSERT... EXEC is a syntactically valid statement in a row with INSERT... VALUES and INSERT... SELECT
Well,..  about 'elegancy'? I can live with this one :-(
0
midfdeAuthor Commented:
This works for me too
SELECT *
FROM openquery([igorinspiron\sqlexpress], 'set fmtonly off exec pacratPatterns..tsRowCounts')
WHERE  [rowcount] >100
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server 2005

From novice to tech pro — start learning today.