Re: How to retrieve results from a dynamic SQL query
- From: James.Shih.Neulion@xxxxxxxxx
- Date: Tue, 19 Jun 2007 13:42:11 -0000
On Jun 18, 7:52 pm, Ed Murphy <emurph...@xxxxxxxxxxxx> wrote:
James.Shih.Neul...@xxxxxxxxx wrote:
On Jun 15, 6:16 pm, Ed Murphy <emurph...@xxxxxxxxxxxx> wrote:
InvestorTrade wrote:
I have a query that is formed dynamically, and I need to be ableCan you replace the query with a stored procedure?
store the result in a variable, and example of this would be:
BEGIN
DECLARE @myresult int
DECLARE @query = 'select count(*) from sysobjects'
SET @myresult = exec (@query)
END
I thought of using Global temporary tables (##) where I could store
the result, but I rather not.
Yes, but how would a store procedure help? I need to store the result
of the query
Because you can feed the output of the stored procedure into a
(non-global) temporary table. Quick example:
create procedure foo as
begin
select bar, baz from the_table
end
create table #foo (bar int, baz varchar(10))
insert into #foo exec foo
select * from #foo
OK - Yes - I knew about the temporary table and already thought about
this too - but I don't want to use it - I think it might be cheaper to
use memory than creating a temp table in the drive - unless temp
tables are created in memory. Thank you for the suggestion, any other
way you may think of?
.
- Follow-Ups:
- Re: How to retrieve results from a dynamic SQL query
- From: Ed Murphy
- Re: How to retrieve results from a dynamic SQL query
- References:
- How to retrieve results from a dynamic SQL query
- From: InvestorTrade
- Re: How to retrieve results from a dynamic SQL query
- From: Ed Murphy
- Re: How to retrieve results from a dynamic SQL query
- From: James . Shih . Neulion
- Re: How to retrieve results from a dynamic SQL query
- From: Ed Murphy
- How to retrieve results from a dynamic SQL query
- Prev by Date: Re: How to retrieve results from a dynamic SQL query
- Next by Date: Strange value in datetime field
- Previous by thread: Re: How to retrieve results from a dynamic SQL query
- Next by thread: Re: How to retrieve results from a dynamic SQL query
- Index(es):
Relevant Pages
|