|
database
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Select Data from a stored procedure from within a stored procedureHi, hopefully this is an easy question to answer (I don't mind feeling
dumb). I have a stored procedure that calls a remoted stored procedure that is selecting data (ie. select name from tblNames) So my question is: How do I access the data from within my stored procedure? (ie. Select * from exec storedProc) Anyone? I cannot figure out how to do it..... ¡¡Gracias!! Ed try insert...exec to dump the result set into a temp table.
"Ed" <e**@nait.ab.ca> wrote in message Hi, hopefully this is an easy question to answer (I don't mind feelingnews:1154118554.257671.40680@m73g2000cwd.googlegroups.com... dumb). I have a stored procedure that calls a remoted stored procedure that is selecting data (ie. select name from tblNames) So my question is: How do I access the data from within my stored procedure? (ie. Select * from exec storedProc) Anyone? I cannot figure out how to do it..... ¡¡Gracias!! Ed Is there any way to do it without using the temp table?
Ed Brian Selzer wrote: Show quote > try insert...exec to dump the result set into a temp table. nope.
Show quote "Ed" <e**@nait.ab.ca> wrote in message news:1154120892.284953.262860@i3g2000cwc.googlegroups.com... > Is there any way to do it without using the temp table? > > Ed > > Brian Selzer wrote: >> try insert...exec to dump the result set into a temp table. > Gad dangit!
Thanks for your help! Ed Brian Selzer wrote: Show quote > nope. > > "Ed" <e**@nait.ab.ca> wrote in message > news:1154120892.284953.262860@i3g2000cwc.googlegroups.com... > > Is there any way to do it without using the temp table? > > > > Ed > > > > Brian Selzer wrote: > >> try insert...exec to dump the result set into a temp table. > > One alternative is to create a loopback and use OPENQUERY like:
EXEC sp_serveroption 'data access', TRUE GO SELECT * FROM OPENQUERY ( Server, 'EXEC usp' ) ; If you have #temp tables used in your stored procedure, you will have to use SET FMTONLY OFF ( to set off the attempt to determine the metadata of the temp table resultset ) within the OPENQUERY like: SELECT * FROM OPENQUERY( Server, 'SET FMTONLY OFF; EXEC usp') ; -- Anith Ed (e**@nait.ab.ca) writes:
> Hi, hopefully this is an easy question to answer (I don't mind feeling Since this is a remote procedure you could do:> dumb). > > I have a stored procedure that calls a remoted stored procedure that is > selecting data (ie. select name from tblNames) > > So my question is: How do I access the data from within my stored > procedure? > > (ie. Select * from exec storedProc) SELECT * FROM OPENQUERY(SERVER, 'EXEC db.dbo.storedProc') OPENQUERY is a rowset function that will return the result set from the other procedure as a table. OPENQUERY will first run the batch in a sort of NOEXEC-mode to look for resultsets and metadata. This may fail under some circumstance, for instance if the remote procedure creates a temp table, as the table is not created in the NOEXEC mode. -- Erland Sommarskog, SQL Server MVP, esq***@sommarskog.se Books Online for SQL Server 2005 at http://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/books.mspx Books Online for SQL Server 2000 at http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx |
|||||||||||||||||||||||