Solved

Convert nvarchar to int in SQL

Posted on 2008-06-11
4
2,633 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
Comment Utility
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 108

Expert Comment

by:Ray Paseur
Comment Utility
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
Comment Utility
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 108

Expert Comment

by:Ray Paseur
Comment Utility
0

Featured Post

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Join & Write a Comment

Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
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.
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

762 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

6 Experts available now in Live!

Get 1:1 Help Now