converting integer field into money

Posted on 2008-10-06
Last Modified: 2012-05-05
I'm converting a data file that has a fee field with no decimals. I need to cast this field as money but I'm stuck on how to proceed with this.


data field = 25557
want to to convert it to show 255.57
Question by:jorbroni
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
LVL 39

Expert Comment

ID: 22654416
select cast(datafield as numeric(10,2)/100
from YourTable
LVL 39

Expert Comment

ID: 22654420
or perhaps this, depending upon your db engine:

select convert(numeric(10,2), yourDataField)/100
from YourTable

Author Comment

ID: 22654464

I get the following error

Arithmetic overflow error converting varchar to data type numeric.
LVL 39

Accepted Solution

BrandonGalderisi earned 250 total points
ID: 22654484
Well 10,2 was just a starting point.  If you have greater than 8 digits to the left (>99 million) then you need to expand your data type beyond 10,2.

Author Comment

ID: 22654491


I figured out what I did wrong with your script.

Thanks for your help sir.

Featured Post

Forrester Webinar: xMatters Delivers 261% ROI

Guest speaker Dean Davison, Forrester Principal Consultant, explains how a Fortune 500 communication company using xMatters found these results: Achieved a 261% ROI, Experienced $753,280 in net present value benefits over 3 years and Reduced MTTR by 91% for tier 1 incidents.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Comparison query - 4 columns 9 42
Convert string date and select older than 30 days from today 2 41
SQL Syntax 6 41
UPDATE JOIN multiple tables 5 20
If you have heard of RFC822 date formats, they can be quite a challenge in SQL Server. RFC822 is an Internet standard format for email message headers, including all dates within those headers. The RFC822 protocols are available in detail at:   ht…
Occasionally there is a need to clean table columns, especially if you have inherited legacy data. There are obviously many ways to accomplish that, including elaborate UPDATE queries with anywhere from one to numerous REPLACE functions (even within…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below.…

756 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question