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.
| Author |
Topic |
|
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2005-08-15 : 07:48:06
|
| Tina writes "hi,I have to copy data from a file to a temporay table & from there to the original table. I have used a procedure to do the same. I need to use a cursor to fetch each record from the temp table check for the below given conditions, update it & then enter it in the original table :If job is CLERK then commission is 5% of salaryIf job is MANAGER then commission is 10% of salaryIf job is DEPUTY MANAGER then commission is 15% of salaryHow do i write a cursor in the procedure & chk for the condition?can i use multiple if-then or any other way? plz suggest" |
|
|
robvolk
Most Valuable Yak
15732 Posts |
Posted - 2005-08-15 : 07:50:35
|
| Sorry, this is SQL Team, we don't know how to write cursors:UPDATE myTableSET Commission=CASE JobTitleWHEN 'CLERK' THEN Salary * 0.05WHEN 'MANAGER' THEN Salary * 0.10WHEN 'DEPUTY MANAGER' THEN Salary * 0.15ELSE Comission ENDThat will update all of the rows and do the calculations you've specified. If this will not work for you you will need to post your code and table structures so we can refine the answer. |
 |
|
|
|
|
|