Solved

Convert nvarchar to int in SQL

Posted on 2008-06-11
4
2,671 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 110

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 110

Expert Comment

by:Ray Paseur
ID: 21762009
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

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

Suggested Solutions

Title # Comments Views Activity
MySQL Error Code 2 27
MS Access - need to reduce row size 25 65
mysql date time 14 43
Why is my $_POST not going to results page 10 39
All XML, All the Time; More Fun MySQL Tidbits – Dynamically Generate XML via Stored Procedure in MySQL Extensible Markup Language (XML) and database systems, a marriage we are seeing more and more of.  So the topics of parsing and manipulating XM…
I use MySQL for many of my development projects in a Windows environment. To manage my databases (and perform queries) for years I used a tool called MySQL administrator.  This tool has since been replaced by MySQL Workbench. So I decided to m…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
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…

733 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