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

  • Home
  • SEARCH
  • 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 7015199
In Process

The Archive Base Latest Questions

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

How to loop update total field in procedures in SQL Server? I have table

  • 0

How to loop update total field in procedures in SQL Server?

I have table 1. I want to create procedures to update total field automation.

Table1

Value 1  Value 2   Total

2         4
3         4
3         3
3         1
3         4

PROCEDURE:

Create PROCEDURE test1
AS

Select value1,value2,(value1*value2) as total from Table1
  • 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:37:15+00:00Added an answer on May 27, 2026 at 10:37 pm
    CREATE PROCEDURE up_UpdateTotals
    AS
    BEGIN
    
      UPDATE Table1 SET Total = Value1 + Value2 WHERE Total IS NULL OR Total <> (Value1 + Value2)
    
    END
    

    Will update totals for where it’s not set or not in sync (in case values change). Can be extended by adding parameters and such, ofcourse.

    Update: Change + to * in case you need to multiply the values instead of add them together.

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

Sidebar

Related Questions

I have a loop on page to update an access database that takes 15-20
I'm trying to update a hashtable in a loop but getting an error: System.InvalidOperationException:
I want to loop over the contents of a text file and do a
I want to loop over the elements of an HTML form, and store the
I have a function that updates a MySQL table from a CSV file. The
How can I force ttk to update the screen? I'm running a long loop
I have a table with 2 varchar2 columns. I have added new number column
I need to reset a boolean field in a specific table before I run
//UPDATE// I found some code to do paging which I have modified to work
I'm working on a game where on each update of the game loop, the

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.