While monitoring a production system, I noticed a lot of "String or binary data would be truncated" exceptions. This is an indication that the string data that would be persisted is larger than the database column allows.
That’s an easy one to fix! So I opened up SQL Server Management Studio, right click on the table that was causing the problem and choose Design from the context menu.
I altered the column size and hit Save. However this resulted in the following message:
SQL Server Management Studio tries to handle the resize operation by executing a ‘DROP’ and re‘CREATE’ of the table. As this would result in a loss of all the data, the operation is prevented.
But I’m making an existing column larger. I would except that this is a safe operation that can be executed without any risk of data loss?
Instead of using the designer I switched to a small SQL snippet:
Remark: Don’t forget to include the ‘NOT NULL’ modifier otherwise you end up with a NULLABLE column.