Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6910469
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T08:49:05+00:00 2026-05-27T08:49:05+00:00

I am not satisfied with answers on Caching SQL queries . I am not

  • 0

I am not satisfied with answers on Caching SQL queries.

I am not interested in 3rd party solutions because this should be a simple problem to solve by myself.

I am looking for an alternative solution to Caching of Linq queries which works with any SQL query, not just Linq. Ideal solution would be to have stored procedure like execsql @Sql,@HashCode, which would query table of serialized results by HashCode and return result if exists, otherwise run query, save serialized result in table of results and return it. Of course returned results must have the same structure as if they were not stored.

Let’s not worry about cache expiration/garbage cleaning or other possible performance issues in this context.

In order to do that I need to be able to detect hash code of SQL query (I suppose GetHashCode on SQL query string will do), serialize and deserialize query result.

Considering that query results may have different structure, I suppose that utilization of FOR XML AUTO would be a good candidate for serialization. But how to deserialize it in generic way so that code does not depend on result structure ?

The solution can use Sql 2008 features if needed.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T08:49:06+00:00Added an answer on May 27, 2026 at 8:49 am

    you could this like that (a stored proc, that’ll wait your table function and your parameters concatenated :

    CacheService(tableFunctionName,parametersConcat)
    
    IF(there_is_no_cache_table)
    BEGIN
       execsql "SELECT * , "+parametersConcat+" as parametersConcat INTO cache_tableFunctionName "++" FROM dbo."+tableFunctionName+"("+parametersConcat+")"
    END
    ELSE IF(there_is_no_cache_entry_for_this_function_and_parameters)
    BEGIN
       execsql "INSERT INTO cache_"+tableFunctionName+" SELECT * , "+parametersConcat+" FROM dbo."+tableFunctionName+"("+parametersConcat+")"
    END
    ELSE  
    BEGIN
       execsql "SELECT *  FROM cache_"+tableFunctionName+" WHERE parametersConcat ='"+parametersConcat+"'"
    END
    

    EDIT : be careful about SQL Injection and everything this is just a starter

    EDIT 2 : you might have to add the cache entry creation date so you can delete them

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm not satisfied with the answers given by the SOAP vs REST questions notably
I have looked on google for answers but I am not satisfied. My Logic:
This is probably a very common problem which has a lot of answers. I
Probably this question repeated, but i am not satiesfied with existing answers. I want
I'm currently using default implementation of STL for VS2005 and I'm not really satisfied
Not sure if this is possible or if I'm expressing correctly what I'm looking
Not that I'm doing something like that, but I am kind of interested how
Not sure how to ask a followup on SO, but this is in reference
Not too long ago, I had a problem which required me to set WinDbg.exe
I'm not satisfied with default set of linestyles, namely the size of line segments

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.