Solved

How to prevent the error: Arithmetic overflow error converting expression to data type nvarchar ?

Posted on 2007-04-02
1
11,937 Views
Last Modified: 2013-12-05
I am developing an Access application with Accesss as the front end and SQL Server as the
backend database.

I have an existing table named tblMutualFunds comprised of the following fields:

MutualID int 4 (Identity)
State nvarchar (2)
Account nvarchar (9)

I also have an Excel file that one of my users created with the fields ResStateCode and Plan.

I use the TransferSpreadsheet command to Import the Excel file into an Access table named tblAppend.
My goal is to append the records from the imported Access table tblAppend into the table named tblMutualFunds.

I noticed that when the tblAppend table gets created, the fields generated are defined as follows:

ResStateCode  nvarchar(255)
[Plan #] float (8)

field ResStateCode of tblAppend correlates to field State on the table tblMutualFund
field [Plan #] of tblAppend correlates to field Account on the table tblMutualFund

When I try to perform the following

insert into dbo.tblMutualFunds
select ResStateCode, [Plan #]
from dbo.tblMuFunds

I get the error message:

Server: Msg 8115, Level 16, State 2, Line 27
Arithmetic overflow error converting expression to data type nvarchar.
The statement has been terminated.

The problem seems to be that the field [Plan #] gets converted from Excel into a Float field.
Now I am trying to insert values from table tblAppend for field Plan of type float
into a field Account of type nvarchar in table tblMutualFunds.

Do you know how I can fix this conversion problem ?
------------------------------------------------------------------------------------------
I was going to try to Alter the table tblMuFunds and alter the column [Plan #] to type nvarchar but I get the following error:

alter table dbo.tblMuFunds
alter column [Plan #] nvarchar not null

Server: Msg 8115, Level 16, State 2, Line 1
Arithmetic overflow error converting expression to data type nvarchar.
The statement has been terminated.
0
Comment
Question by:zimmer9
1 Comment
 
LVL 142

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 500 total points
ID: 18841419
I would first convert from float to decimal, int or bigint (depends on the data), and in a second step to nvarchar.
you might need to create another column with the intermediate data first...
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Suggested Solutions

In the previous article, Using a Critera Form to Filter Records (http://www.experts-exchange.com/A_6069.html), the form was basically a data container storing user input, which queries and other database objects could read. The form had to remain op…
I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

758 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now