Caching result of SELECT statement for reuse in multiple queries
Posted
by
Andrew
on Stack Overflow
See other posts from Stack Overflow
or by Andrew
Published on 2012-01-19T06:15:29Z
Indexed on
2012/03/20
11:29 UTC
Read the original article
Hit count: 172
I have a reasonably complex query to extract the Id
field of the results I am interested in based on parameters entered by the user.
After extracting the relevant Ids I am using the resulting set of Ids several times, in separate queries, to extract the actual output record sets I want (by joining to other tables, using aggregate functions, etc).
I would like to avoid running the initial query separately for every set of results I want to return. I imagine my situation is a common pattern so I am interested in what the best approach is.
The database is in MS SQL Server and I am using .NET 3.5.
© Stack Overflow or respective owner