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 |
dbonneau
Yak Posting Veteran
50 Posts |
Posted - 2012-11-11 : 05:07:47
|
Hi,I have a following syntax but I get error"operand data type nvarchar is invalid for subtract operator "update my_tableset Total_field = ( Field_A - Field_B) from my_table;Thank you |
|
sunitabeck
Master Smack Fu Yak Hacker
5155 Posts |
Posted - 2012-11-11 : 07:16:03
|
You will need to cast field_a and field_b to a numeric type if they are of character type - for exampleupdate my_tableset Total_field = ( cast(Field_A as float) - cast(Field_B as float)) from my_table; |
|
|
dbonneau
Yak Posting Veteran
50 Posts |
Posted - 2012-11-11 : 18:11:25
|
quote: Originally posted by sunitabeck You will need to cast field_a and field_b to a numeric type if they are of character type - for exampleupdate my_tableset Total_field = ( cast(Field_A as float) - cast(Field_B as float)) from my_table;
Thank you so much ! It works good ! |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2012-11-17 : 03:20:44
|
But why do you store numerals in character datatypes? Always use proper datatype based on the nature of dataMadhivananFailing to plan is Planning to fail |
|
|
|
|
|