user1583583
user1583583

Reputation: 1

Update using cursor in SQL Server

I have two tables department and employee.

In the department table I have three columsn: DEP_ID, NAME, HIKEINPERCENT

In the employee table I have four columns: EMP_ID, DEP_ID, EMP_NAME, SALARY

Now if I update the HIKEINPERCENT in the department table, it should update the SALARY of the employees in the employee table by using CURSOR in SQL Server.

PLS GUIDE WITH EXPLANATION..

Upvotes: 0

Views: 325

Answers (1)

Dominic Goulet
Dominic Goulet

Reputation: 8113

Don't use a cursor. If you update the department HIKEINPERCENT field, you should have the DEP_ID to do so, something like :

update department set HIKEINPERCENT = @someNewValue where DEP_ID = @DepartementId

Then, you should update the SALARY in the employee table using something like :

update employee set SALARY = @SomeCrazyNewValue where DEP_ID = @DepartmentId

If this does not help you, please provide more specific info in the OP.

Upvotes: 1

Related Questions