How to increase the size of a VARCHAR column in SQL Server? Options

davegate 138 - 876
@2019-12-25 13:54:17

The following SQL command can be used to increase the size of a VARCHAR column in SQL Server:

ALTER TABLE Department ALTER COLUMN Description VARCHAR (500)

This command increases the length of Description column of Despartment table to 500 characters. You can use the same command to increase the length of CHAR, NCHAR or NVARCHAR columns as well.

You can also use the same command to increase the length of any other type of the column as well. Similarly, you can also modify other properties of columns e.g. constraints, but beware with existing data e.g. if you try to make a  NULL column to NOT NULL then there would be many rows which will violate this constraint, hence, database will not allow you to change that property of column, until you remove those offending rows.

 
Users browsing this topic
Guest