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 |
|
tokue
Starting Member
16 Posts |
Posted - 2010-08-20 : 08:04:59
|
| Hi everybody,perhaps my problem is easy for you.I have a field with data type (int) in one of my tables, I want a sql statement that update that field without selecting it first and making calculations and then updating it, I tried this statement but it doesn't work:UPDATE items SET itemAmount = (+ 5) WHERE ID=@IDwhat I am trying to do is updating that field by adding the number 5 to what ever number it has....Is that possible? |
|
|
vaibhavktiwari83
Aged Yak Warrior
843 Posts |
Posted - 2010-08-20 : 08:12:30
|
| UPDATE items SET itemAmount = itemAmount + 5 WHERE ID=@IDVaibhav TTo walk FAST walk ALONE To walk FAR walk TOGETHER |
 |
|
|
tokue
Starting Member
16 Posts |
Posted - 2010-08-20 : 08:15:27
|
I found the solution by playing around UPDATE items SET itemAmount = (itemAmount + 5) WHERE ID=@ID |
 |
|
|
tokue
Starting Member
16 Posts |
Posted - 2010-08-20 : 08:17:25
|
I wrote my last words before seeing your answer dear vaibhavktiwari83, Thank you... |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2010-08-20 : 08:35:11
|
| If the version is from 2008,UPDATE items SET itemAmount+ = 5 WHERE ID=@IDMadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|