Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Convert nvarchar to int in SQL

Posted on 2008-06-11
4
Medium Priority
?
2,714 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 111

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 2000 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

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone 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

Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
In this blog post, we’ll look at how ClickHouse performs in a general analytical workload using the star schema benchmark test.
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

604 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