Solved

Convert Dec to Int

Posted on 2009-07-09
3
181 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 250 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 250 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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

This article will describe one method to parse a delimited string into a table of data.   Why would I do that you ask?  Let's say that you need to pass multiple parameters into a stored procedure to search for.  For our sake, we'll say that we wa…
by Mark Wills Attending one of Rob Farley's seminars the other day, I heard the phrase "The Accidental DBA" and fell in love with it. It got me thinking about the plight of the newcomer to SQL Server...  So if you are the accidental DBA, or, simp…
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…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

734 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