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
 SQL Server 2005 Forums
 Transact-SQL (2005)
 How to change the sign of a number value during an

Author  Topic 

pras2007
Posting Yak Master

216 Posts

Posted - 2009-10-14 : 21:56:36
Hello All,

I have a table that I want to insert the values into another table. The problem is that I want to change the signs in the result table. Does anyone know if there is a function that can change the signs automatically during insert operation?
Table_A

COL1 COL2 COL3
10 30 -29
39 -23 45

Result

COL1 COL2 COL3
-10 -30 29
-39 23 -45

Please advice.

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2009-10-14 : 22:08:54
[code]
select -COL1, -COL2, -COL3
from yourtable
[/code]


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

Go to Top of Page

pras2007
Posting Yak Master

216 Posts

Posted - 2009-10-14 : 22:42:50
Thanks for the response Khtan, I can also multiple the col by -1 to accomplish the task.
Go to Top of Page
   

- Advertisement -