Advertisement

07.02.2008 at 10:53AM PDT, ID: 23534438
[x]
Attachment Details

need a loop for update records

Asked by ewang1205 in MS SQL Server

Tags: sql server

I have emp table with 3 columns:  emp_no, salary and remaining_salary.  I have a total 1000 to begin with.  Now, I like a loop to update (like update emp set remaining_salary = 1000- salary  ) to display the following the result data. When comes to 0 then exit.   How to do this in a for loop?  Thanks.

emp_no  salary   remaining_salary
1             300           700
2              400          300
3              500          0
4          600             0Start Free Trial
[+][-]07.02.2008 at 12:54PM PDT, ID: 21920054

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: MS SQL Server
Tags: sql server
Sign Up Now!
Solution Provided By: YZlat
Participating Experts: 1
Solution Grade: B
 
 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628