Solved

Convert Dec to Int

Posted on 2009-07-09
3
175 Views
Last Modified: 2012-05-07
I have a DB column that by mistake I made a decimal(18, 2) datatype.  What I have now is the fact I have 3000 records in my table now and need it to be an int datatype.   Is there an easy way to fix this?  Even though its a decimal datatype there are no records that are in decimal formal.
0
Comment
Question by:chrisryhal
3 Comments
 
LVL 75

Accepted Solution

by:
Aneesh Retnakaran earned 250 total points
Comment Utility
create a new column with int / bigint datatype
ALTER TABLE tableName ADD newColumn int
UPDATE tableName SET NewCOlumn = CAST (decimalColumn as int )
ALTER TABLE TableName DROP COLUMN decimalColumn
exec sp_Rename 'tableName.NewColumn', 'DecimalColumn', 'Column'
0
 
LVL 17

Assisted Solution

by:pssandhu
pssandhu earned 250 total points
Comment Utility
ALTER TABLE <TableName>
ALTER COLUMN <ColumnName> <New DataType>
Eg.
ALTER TABLE MyTable
ALTER COLUMN Amount INT
P.
0
 
LVL 2

Author Closing Comment

by:chrisryhal
Comment Utility
Thanks!!  Got it converted
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Data architecture is an important aspect in Software as a Service (SaaS) delivery model. This article is a study on the database of a single-tenant application that could be extended to support multiple tenants. The application is web-based develope…
This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

744 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

20 Experts available now in Live!

Get 1:1 Help Now