Solved

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

Posted on 2007-04-02
1
11,947 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

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…
In Debugging – Part 1, you learned the basics of the debugging process. You learned how to avoid bugs, as well as how to utilize the Immediate window in the debugging process. This article takes things to the next level by showing you how you can us…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

920 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

17 Experts available now in Live!

Get 1:1 Help Now