Changing DataType Of Existing Column In SQL Server 2008

In this article I describe how to change the datatypes of column which already exists in table.
  • 2235

In this article I describe how to change the datatypes of column which already exists in table.

To change data type of existing column, lets see following step by step process.

Step1

Create table

use person

create table Table1

(ID int, name varchar(5),percentage int)

GO

Step 2

Once we created table, now later we need to enter the name having more than 5 characters, so change the data type of this column:

alter table Table1

alter column name varchar(50)

GO

Step 3

Change the data type of percentage from int to float as shown below:

alter table Table1

alter column percentage float

GO

Step 4

You can see all the data types of columns using following code snippet:

 changeDataType.jpg

© 2019 DotNetHeaven. All rights reserved.