MS Access Query - Overflow

Hi Experts,

I have this part of a query:
Val(Nz([InvoiceNR]))

I am getting a overflow error.

I do not do any arthritic or is there any decimals

This is a conversion.
From:
InvoiceNr(nvarchar(20), null)
To:
InvoiceNr(PK, int, not null)

Please help and thanks
Amour22015Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

MlandaTCommented:
What are the values in the column? Perhaps you have values that are too big to be represented as numerics in access?
0
Amour22015Author Commented:
How can you tell which are numbers and which are not?

The field I am converting from is InvoiceNr(nvarchar(20), null)

Like:

123456

Vs

12345.6

Please help and thanks...
0
MlandaTCommented:
Try adding this to your SELECT statement

Where IsNumeric(InvoiceNr) = 1
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

MlandaTCommented:
Curiously though... You say MS ACCESS and yet your question references SQL Server data types nvarchar. Knowing exactly which is which helps us know exactly what were working with and how to help
0
Amour22015Author Commented:
I am using MS Access to run the conversion query.

I see nvarchar in the ssms window.

Data gets imported into ssms

I use External Data> ODBC Database>Import the source data into a new table int the currnt database>Machine Data Source>Import Objects

To get the table from ssms to access.

So I am running the query in access to Insert into the new tables...

I ran this query (in TSQL) to find all none numeric:
SELECT [txtInvoiceNo]
  FROM [SIOP_siophal].[dbo].[tblAccounting]
  Where txtInvoiceNo like '%[^0-9]%'

Open in new window


But have filtered them out yet still get the same error...


The view works fine, it happens when I run.



Please help and thanks...
0
MlandaTCommented:
SELECT  CAST( [txtInvoiceNo] as int) NewInvoiceNr
  FROM [SIOP_siophal].[dbo].[tblAccounting]
  Where txtInvoiceNo like '%[^0-9]%'
ORDER BY NewInvoiceNr DESC

Does that work in SSMS? What is the biggest value you see there?
0
Amour22015Author Commented:
So I got this:
Msg 248, Level 16, State 1, Line 1
The conversion of the nvarchar value '3165101084' overflowed an int column.

What does this mean?

Please help and thanks
0
MlandaTCommented:
3,165,101,084

That is the problem. Those figures are bigger than the max value for the data INT and NUMERIC in Access. An overflow in this case, means the value is too big for the data type you are working with. SQL Server has got the BIGINT data type which will take this value. For Microsoft Access here are the maximum value: https://support.office.com/en-us/article/Introduction-to-data-types-and-field-properties-30ad644f-946c-442e-8bd2-be067361987c#bm2g 

My next question is why you want to convert invoice numbers to numerics with the VAL formula? You never do arithmetic on them. Why not just leave them as Text?
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Amour22015Author Commented:
Thanks for helping... Great
0
MlandaTCommented:
Glad to help.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.