473,387 Members | 1,502 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

How to convert int to decimal

BCS
I have a table called BOLDetail and I need to update a column called "Tons"
from int to decimal with a precision of 5 and scale of 3. I attempted to
change the setting in Table Design but received an error when trying to save
my changes.

There's only about 12 records in this particular table, so I guess I could
delete their Tons value and then update the Table Design and reinsert the
values afterwards. Just wondering what the proper syntax would be to convert
them in their present state.

Thanks,

Barry
Jul 20 '05 #1
1 12119
What was the error you received?

Was it something like

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

Could it be the data in the INT attribute is too big to fit the new
datatype?

For example

CREATE TABLE IntNowWillBeDecimal(col1 int)
GO
INSERT IntNowWillBeDecimal VALUES(1)
INSERT IntNowWillBeDecimal VALUES(100)
INSERT IntNowWillBeDecimal VALUES(1000)
INSERT IntNowWillBeDecimal VALUES(10000)
INSERT IntNowWillBeDecimal VALUES(100000)
GO
ALTER TABLE IntNowWillBeDecimal ALTER COLUMN Col1 decimal(5,3)
If you want 3 places after the decimal then the highest number you can have
in the INT attribute before conversion is 99.
--
--

Allan Mitchell MCSE,MCDBA, (Microsoft SQL Server MVP)
www.SQLDTS.com - The site for all your DTS needs.
I support PASS - the definitive, global community
for SQL Server professionals - http://www.sqlpass.org
"BCS" <bc*******@hotmail.com> wrote in message
news:Ef*******************@twister.southeast.rr.co m...
I have a table called BOLDetail and I need to update a column called "Tons" from int to decimal with a precision of 5 and scale of 3. I attempted to
change the setting in Table Design but received an error when trying to save my changes.

There's only about 12 records in this particular table, so I guess I could
delete their Tons value and then update the Table Design and reinsert the
values afterwards. Just wondering what the proper syntax would be to convert them in their present state.

Thanks,

Barry

Jul 20 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
by: Jason | last post by:
Could someone here show me how I would write a vb program to convert decimal ip address to binary? For example a small form with a convert button and a label for the result and a textbox for the...
5
by: Ray | last post by:
I have a table with some audit date and time columns. Problem is the developer who stored the data left them as DECIMAL type instead of DATE and TIME. Is there a way I can convert the DECIMAL type...
13
by: muss | last post by:
how to convert decimal number in a hexadecimal number using C? Please help me. Thanks.
5
by: lathasree | last post by:
Hi, this is sreelatha give a c progrm to convert decimal to binary.... thank u....
6
by: sweeet_addiction16 | last post by:
hello Im writin a code in c... can sum1 pls help me out in writing a c code to convert decimalnumber to hexadecimal number.The hexadecimal number generated has to be an unsigned long.
1
by: karanbikash | last post by:
Hi , I have a requirement where in I need to display the decimal value of 0.00 as '######.00' SELECT case when DECIMAL(AMT_CHEQUE,31,2) = 0.00 THEN 9999999999999.9999999 ELSE ...
2
nirmalsingh
by: nirmalsingh | last post by:
Hai all, i want to convert decimal to time. for example if i have decimal number 09.6 then i need it as 10.00 and also decimal 10.118 as 11.58. How to convert this? Thanx in advance with Cheers...
1
by: Vitaliy | last post by:
Hi I got this wired exception periodically (Python 2.5, Django based application) what does it mean ?
4
by: Rolandas | last post by:
Hi, Can anyone help me? I need a code in VBA which would convert decimal numbers to the other system bases on number 36. e.g. in this page...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.