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 |
|
putane.sanjay
Yak Posting Veteran
77 Posts |
Posted - 2006-12-11 : 08:34:57
|
| iam new sql server database if i want update salaries for below conditions how to write cursor for thisupdate salary 2000 whose sal between 5000 to 10000 update salary 3000 whose sal between 10000 to 15000 update salary 5000 whose sal between 15000 to 20000 please help me |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2006-12-11 : 08:38:46
|
CURSOR?UPDATE YourTableNameHereSET Salary = CASE WHEN Salary BETWEEN 5000 AND 9999 THEN 2000 WHEN Salary BETWEEN 10000 AND 14999 THEN 3000 WHEN Salary BETWEEN 15000 AND 19999 THEN 5000 ELSE 0 END + Salary Peter LarssonHelsingborg, Sweden |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2006-12-11 : 08:39:51
|
OrUPDATE YourTableNameHereSET Salary = CASE WHEN Salary BETWEEN 5000 AND 9999 THEN 2000 WHEN Salary BETWEEN 10000 AND 14999 THEN 3000 WHEN Salary BETWEEN 15000 AND 19999 THEN 5000 END + SalaryWHERE Salary BETWEEN 5000 AND 19999 Peter LarssonHelsingborg, Sweden |
 |
|
|
robvolk
Most Valuable Yak
15732 Posts |
Posted - 2006-12-11 : 13:56:15
|
Or:UPDATE YourTableNameHereSET Salary = CASE WHEN Salary <10000 THEN 2000 WHEN Salary <15000 THEN 3000 ELSE 5000 END + SalaryWHERE Salary BETWEEN 5000 AND 19999 |
 |
|
|
putane.sanjay
Yak Posting Veteran
77 Posts |
Posted - 2006-12-12 : 03:07:12
|
| thank u for ur suggestions |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2006-12-12 : 03:08:48
|
| I hope we didn't upset your professor with this alternative solution...Peter LarssonHelsingborg, Sweden |
 |
|
|
|
|
|