Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Batch update

Author  Topic 

sara
Starting Member

4 Posts

Posted - 2007-08-12 : 05:06:33
Hai, i would like to do Bulk update to avoid the round trip to the database.
Means, In my UI im dsiplaying all the employee details who are related to one particular dept. Now i want to update the bonus to all the employees based on their category. UI changes are refelected in the Datatable(.NET). Finally the datatable changes i would like to update in the Database.
how can i do that..
sample code pls.
im very very new to sql

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2007-08-12 : 10:14:28
Can you post your table's DDL, some sample data and the expected result ?


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

sara
Starting Member

4 Posts

Posted - 2007-08-12 : 19:57:07
quote:
Originally posted by khtan

Can you post your table's DDL, some sample data and the expected result ?


KH
[spoiler]Time is always against us[/spoiler]





My Table is this.
DeptId EmpId Grade Salary IsBonus BounsAmt
100 100001 M1 30000 y 3%
100 100002 M2 25000 y 2.80%
100 100003 M8 5000 y 1%


My UI look like this
Depar EmpId Grade IsBonus Percentage of Bonus Amt
Admin 100001 M1 y 3% 30900
Admin 100002 M2 y 2.80% 25700
Admin 100003 M8 y 1% 5050
So finally i want to update all the three records into the database. But i should go to the database only once. Not everytime for every record.
Help pls



Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2007-08-12 : 21:13:44
[code]
select *, Bonus_Amt = Salary * ((100 + BounsAmt) / 100.0)
from yourtable
[/code]


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page
   

- Advertisement -