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 |
|
Ali T
Starting Member
22 Posts |
Posted - 2009-02-01 : 09:23:25
|
| dear allI have a table with two columns A and B. I want to insert the content of column A Which are numbers, to column B under the following condition:If the the record in A is positive insert the same quantity into column B but if it is negative (0>) multiply it by (-1) and then insert it into Column B. and Now aI need the query by using UPDATE command.help me with this please.RagardsAli |
|
|
sodeep
Master Smack Fu Yak Hacker
7174 Posts |
Posted - 2009-02-01 : 10:40:56
|
| [code]Update TSet T.B =(Case when T.A >0 then T.A else T.A *(-1) end)from Table T[/code] |
 |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2009-02-01 : 11:31:44
|
So you want always positive values in column B?Update Tableset B = ABS(A) GreetingsWebfred No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2009-02-01 : 12:30:08
|
| [code]Update TSet T.B =SIGN(T.A)* T.A from Table T[/code] |
 |
|
|
|
|
|