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 7015065
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T22:36:14+00:00 2026-05-27T22:36:14+00:00

I have a stored procedure that is not only huge, but very memory intensive.

  • 0

I have a stored procedure that is not only huge, but very memory intensive. This first stored procedure is created for a detail report. The second stored procedure calls the first stored procedure, places the information into a Temporary table and then selects the information from that temporary table and summarizes it.

Now, the second stored procedure doesn’t need all of the information in the detail stored procedure, it only needs some of it.

Our DBA has called this approach reckless and has made other suggestions, such as “persist this to a real table so that it is run one-time per day”. This actually isn’t going to happen because numerous users can run either report numerous times per day and for different date ranges. His other suggestion was to SUM without the temp table, but I’m not sure how you select from one stored procedure only certain fields.

I have two questions: How would I follow his second suggestion of SUM without the temp table and if that can’t be done, does anyone have any suggestions on the best approach to use to summarize the needed data for the Summary report?

Both of these stored procedures are for separate reports. One is for the detail and the other report is the summary. The end users can run them for different stores and different time periods.

  • 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-27T22:36:14+00:00Added an answer on May 27, 2026 at 10:36 pm

    Why not put the data in a view and hit the view from both stored procs? This would reduce the complexity in both procs (but move it to the view).

    Depending on the structure of your query you could possibly even create an indexed view which would create a persisted form of the data and allow you to make use of indexes.

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

Sidebar

Related Questions

I have a SQL Server stored procedure that is not returning any data when
I have this stored procedure that I want to use for my SAP crystal
I have a stored procedure that has this line: SET @SQL = 'SELECT path,title,tags
I have a stored procedure that logs some data, how can I call this
I have a stored procedure that returns multiple resultsets, it looks something like this
I have an update statement in a stored procedure that looks generally like this:
I have a stored procedure that is updating a very large table (with over
I have a stored procedure that has the parameter: @desk VARCHAR(50) I want to
I have a stored procedure that returns data in the format of: Date |
I have a stored procedure (that I didn't write) that uses openquery to populate

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.