sqlsql-serveralter-tablealter-column

SQL Server - Alter column length causes collateral damage?


Besides the obvious possible data loss, when altering the size from varchar(MAX) to varchar(255), are there any side effects? Like:

This is the kind of activity that can be conducted at any time of day or it should be confined to a "maintenance window"?


Solution

  • In changing the varchar(max) column to varchar(n) or vice versa, SQL Server will update all rows of the table. This can temporarily increase the size of the table until rebuild cluster index or execute DBCC CLEANTABLE.