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 |
|
sanjay5219
Posting Yak Master
240 Posts |
Posted - 2010-10-11 : 12:18:02
|
| Dear All,I have two columns 1.Paid_Amount 2.Set_Amount and both are varchar in SQL.Now i have to convert both the columns in decimal because i want to show the 2 values after decimal and i have to show the subtraction.Please help |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2010-10-11 : 12:20:00
|
| use cast() or convert(). also make sure values coming are numeric else convertion will break------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
sanjay5219
Posting Yak Master
240 Posts |
Posted - 2010-10-11 : 12:25:02
|
| Select convert(decimal(5,2),[Paid_Amount])as Paid_Amount but getting this errorMsg 8115, Level 16, State 8, Line 1Arithmetic overflow error converting numeric to data type numeric. |
 |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2010-10-11 : 13:14:38
|
decimal(5,2) means: only 5 characters including the decimal point!So the highest possible value for decimal(5,2) is 99,99 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 - 2010-10-17 : 02:59:57
|
quote: Originally posted by sanjay5219 Select convert(decimal(5,2),[Paid_Amount])as Paid_Amount but getting this errorMsg 8115, Level 16, State 8, Line 1Arithmetic overflow error converting numeric to data type numeric.
first determine whats the max numeric value you need to store in field. then use precision and scale values accordingly------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
|
|
|
|
|