Solved

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

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

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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

AutoNumbers should increment automatically, without duplicates.  But sometimes something goes wrong, and the next AutoNumber value is a duplicate.  This article shows how to recover from this problem.
Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
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…

679 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