Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
After having created a table and inserted values in it, is there any way to change the length of the datatypes in SQL Server?

You can use the Alter Table command.
Example:
Alter Table <tablename>
Alter Column <columnname> <datatype>If you had a table named Employee and column LastName that was originally varchar(20) and you wanted to make it varchar(22),use
Alter Table Employee
Alter Column LastName varchar(22)
If you want to make the column shorter and that would result in truncating data you will get an error. In that case, first run an update to truncate the data yourself.
Such as:Update Employee
Set LastName = Substring(Lastname, 1, 15)Alter Table Employee
Alter Column Employee varchar(15)

![]() |
![]() |
![]() |
| Login or Register to Reply | |
| Login | Register |
| Ads by Google |