Click here to Skip to main content
15,884,176 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi i want to change Datatype of Column from int to numeric(18,2) without Dropping the table

plz help
in designer and query
Posted
Comments
Richard C Bishop 7-Apr-14 13:58pm    
If you change it and try to save and it says you have to drop it to make that change, that is what you have to do.
Sachin MCA2012 7-Apr-14 14:02pm    
no i dont want to drop the table and re-create
Sergey Alexandrovich Kryukov 7-Apr-14 14:13pm    
Develop a solution doing it for 99 rows. It will be applicable to 100 rows as well.
—SA

INT to NUMERIC is simple:

SQL
ALTER TABLE MyTable
ALTER COLUMN MyInt numeric(18,2)

If you get an error
The object 'DF_MyTable_MyInt' is dependent on column 'MyInt'.
Then edit your table definition, and remove any DEFAULT value first - SQL creates an automatic constraint on columns with DEFAULT values set. You can always add the Default value back afterwards with a NUMERIC value.
 
Share this answer
 
you should run a query like the next one:
SQL
Alter table dbo.TableTest Alter Column test numeric(18,2)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900