Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Convert Dec to Int

Posted on 2009-07-09
3
Medium Priority
?
184 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
[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
3 Comments
 
LVL 75

Accepted Solution

by:
Aneesh Retnakaran earned 1000 total points
ID: 24815277
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 1000 total points
ID: 24815281
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
ID: 31601691
Thanks!!  Got it converted
0

Featured Post

Nothing ever in the clear!

This technical paper will help you implement VMware’s VM encryption as well as implement Veeam encryption which together will achieve the nothing ever in the clear goal. If a bad guy steals VMs, backups or traffic they get nothing.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There are some very powerful Dynamic Management Views (DMV's) introduced with SQL 2005. The two in particular that we are going to discuss are sys.dm_db_index_usage_stats and sys.dm_db_index_operational_stats.   Recently, I was involved in a di…
In this article I will describe the Copy Database Wizard method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…

688 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