Wednesday, August 17, 2011

How to: Modify Column Data Types (Visual Database Tools)

To modify the data type of a column


1.In Object Explorer, right-click the table with columns for which you want to change the scale and click Design.
The table opens in Table Designer.

2.Select the column for which you want to modify the data type.

3.In the Column Properties tab, click the grid cell for the Data Type property and choose a new data type from the drop-down list.

The new data type is assigned to the column after you click outside the grid cell or use the TAB key to move to another grid cell. It takes effect in the database when you save your changes in Table Designer.

Some time it does not work. Especially if there is a table dependancy (constraints ) and data.
So that time, run the script.

ALTER TABLE table ALTER COLUMN column_name new_data_type


Example .
ALTER TABLE MyTable ALTER COLUMN MyColumn NVARCHAR(100)

No comments:

Post a Comment

Health Benefits of Cashews

  Benefits of Cashews. Healthy food is an integral part of healthy body. Regular exercises such as Yoga and healthy diet is important to...