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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T23:53:54+00:00 2026-05-26T23:53:54+00:00

I have a SQL Stored Procedure which is never ending because of some values

  • 0

I have a SQL Stored Procedure which is never ending because of some values which are cached. But that is just a guess after debugging the procedure.

    while @poid is not NULL
    BEGIN

        Update Item set Sales = (Select Sales from V_ITEM_Hierarchy where POID=@poid) where ItemID=@poid

        Select @poid = i.ItemID
        from V_ITEM_Hierarchy t inner join Item i on (t.POID = i.POID)
        where ( abs(coalesce(t.Sales,0)-coalesce(i.Sales,0)) > 0.0001

    END

I update the value “Sales” in Table Item with the Sales value of a view called “V_ITEM_Hierarchy” and then look again for values which are different. When I debug through the procedure the select-statement always returns the same value even if the Sales values are not different anymore because they were updated.

I tried to insert the command “DBCC DROPCLEANBUFFERS” but the select-statement still returns old values.

  • 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-26T23:53:55+00:00Added an answer on May 26, 2026 at 11:53 pm

    If the second query does not return any rows the value of @poid will NOT be updated. What you need is

    while @poid is not NULL
    BEGIN
    
        Update Item set Sales = (Select Sales from V_ITEM_Hierarchy where POID=@poid) where ItemID=@poid
    
        set @poid = null
    
        Select @poid = i.ItemID
        from V_ITEM_Hierarchy t inner join Item i on (t.POID = i.POID)
        where ( abs(coalesce(t.Sales,0)-coalesce(i.Sales,0)) > 0.0001
    
    END
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have sql stored procedure which pass and return some values: CREATE PROCEDURE [dbo].[GetMoney]
Hai Techies, I have some stored procedure which was written in SQL server.Now i
I have a Stored Procedure which executes some dynamic SQL. I want to use
SQL Server 2005. I have a stored procedure which accepts a few parameters that
I have a SQL server stored procedure which would accept date as input param
I have a messy stored procedure which uses dynamic sql. I can debug it
I have a complex sql query that I have in a stored procedure and
My limited SQL knowledge prompted this post! I have a stored procedure that runs
I have a stored procedure which is building a dynamic sql query and then
I have a SQL Server 2008 stored procedure which does a select count(*) ...

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.