Solved

Convert nvarchar to int in SQL

Posted on 2008-06-11
4
2,663 Views
Last Modified: 2012-05-05
Hi Experts,
I would like to convert "005000000000" currently in varchar(12) into just show "5000000000", tried to convert into int but has the following error

"Msg 248, Level 16, State 1, Line 1
The conversion of the varchar value '005000000000' overflowed an int column. Maximum integer value exceeded."

Reason not using substring function is the value will always change so substring wont work =\

Please kindly assist
0
Comment
Question by:salesprod
  • 2
4 Comments
 
LVL 16

Expert Comment

by:brad2575
ID: 21761573
The number is too long for an int, you can try a long data type (instead of int).  

note:  I have not confirmed that "long" is a data type in MYSQL but it would be something like that, if not "long" then "number".
0
 
LVL 109

Expert Comment

by:Ray Paseur
ID: 21761980
You should consider using a DECIMAL field, however a BIGINT field might do the trick.
0
 
LVL 12

Accepted Solution

by:
AdrianSRU earned 500 total points
ID: 21761983
The largest integer column type in MySQL is bigint.  If you will never have negative numbers then you may want to use unsigned bigint.


--Adrian
0
 
LVL 109

Expert Comment

by:Ray Paseur
ID: 21762009
0

Featured Post

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Using in clause in query with many values 7 53
join tables 4 56
myqsl update statement on phpMyAdmin 8 36
Combining Queries 7 27
I have been using r1soft Continuous Data Protection (http://www.r1soft.com/linux-cdp/) for many years now with the mySQL Addon and wanted to share a trick I have used several times. For those of us that don't have the luxury of using all transact…
Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

791 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