Click here to Skip to main content
15,916,693 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
How to modify the datatype of a particular column in a table using sql scripts
Posted

Probably using Below Snippet.

SQL
ALTER TABLE table_name
 MODIFY column_name column_type;


Or you could refer full article,
http://www.techonthenet.com/sql/tables/alter_table.ph[^]

Please vote and Accept Answer if it Helped.
 
Share this answer
 
Data will be truncated in case field type is changed for some data types.

also not all fields can be changed

following is the example of alter column datatype

Create table testTable (field1 int)
--to convert integer field to varchar
alter table testTable alter column field1 varchar(20)
 
Share this answer
 
I think Hiren given right answer for the question.
 
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