Avatar of vijay1507
vijay1507

asked on 

convert float column to numeric

Hi ,

 I have a float coloun with a id and values are like "2.14966375804504E+17"  and when I try to convert them to Numeric using

ALTER TABLE  [ttoptest].[dbo].[HDS_20080204]
        ALTER COLUMN VISID numeric (25) NOT NULL

I get an error saying

Msg 8115, Level 16, State 6, Line 1
Arithmetic overflow error converting float to data type numeric.
The statement has been terminated.

can some one please help!!!
Microsoft SQL Server 2008Microsoft SQL Server 2005

Avatar of undefined
Last Comment
vijay1507
Avatar of Sharath S
Sharath S
Flag of United States of America image

try to convert the folat value to decimal.
ALTER TABLE  [ttoptest].[dbo].[HDS_20080204]
        ALTER COLUMN VISID decimal(18,6) NOT NULL

Open in new window

Avatar of vijay1507
vijay1507

ASKER

Hi Sharat ,

 This is not working ,I am still getting the same error !!
18,6 means 12 digits before the comma, and 6 after the comma, so for a value of 2.xxxE17  this is not enough

can you try bigint?
anyhow, what IS the biggest value?

select max(VISID) from yourtable
Avatar of vijay1507
vijay1507

ASKER

HI  I have also tried bigint in vien
 actually this is a coloum that has been transfered from Oracle
and this is a std 17 digit number
Avatar of Sharath S
Sharath S
Flag of United States of America image

agree with angel. did you run the query
select max(VISID) from yourtable
ASKER CERTIFIED SOLUTION
Avatar of Mark Wills
Mark Wills
Flag of Australia image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of vijay1507
vijay1507

ASKER

HI Guys I agree with all of your solutions ,I found that there is a 37 digit number in there :) so  actually what I did is that I deleted the whole data and pulled the whole data from Oracle as Number 38 ( which is max I can go )

Thanks for all your support!!!
and happy Christmas
Microsoft SQL Server 2005
Microsoft SQL Server 2005

Microsoft SQL Server 2005 is a suite of relational database management system (RDBMS) products providing multi-user database access functionality.Component services include integration (SSIS), reporting (SSRS), analysis (SSAS), data quality, master data, T-SQL and performance tuning. It includes support for managing XML data and allows a database server to be exposed over web services using Tabular Data Stream (TDS) packets encapsulated within SOAP (protocol) requests.

72K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo