HiveBrain v1.2.0
Get Started
← Back to all entries
patternsqlCritical

Changing column width

Submitted by: @import:stackexchange-dba··
0
Viewed 0 times
changingwidthcolumn

Problem

Will increasing a column (nvarchar) width necessarily drop the table?

In other words, can the width be changed in a production environment with active users?

I figured that if the size is increasing (as opposed to decreasing) this wouldn't be a problem.

Solution

If you're doing it through a T-SQL statement such as below, then no table drop will occur and you can safely do it in a production environment:

alter table  alter column  nvarchar(biggernumber) [not] null


If you do it through the SSMS Design Table GUI, it will depend on what script it decides to use to implement the change. Sometimes it will insert data into a temporary table, drop the original table, create a new version of that table, and insert it back into the new one. An easy way to find out what it will do is to click the "Generate Script" button and look at the T-SQL it plans on executing.

Code Snippets

alter table <table> alter column <column> nvarchar(biggernumber) [not] null

Context

StackExchange Database Administrators Q#5211, answer score: 56

Revisions (0)

No revisions yet.