Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2012 Forums
 SQL Server Administration (2012)
 Estimating transaction log size after adding col

Author  Topic 

ranvir_2k
Posting Yak Master

180 Posts

Posted - 2013-09-25 : 10:14:55
Hi all,

I'm planning on adding an nvarchar(255) column to an existing table that has 24 million rows. The new column will have null values initially.

The table is 4GB in size.

Is there any way to calculate how much this will cause the transaction log to grow to?



Thanks

James K
Master Smack Fu Yak Hacker

3873 Posts

Posted - 2013-09-25 : 10:43:06
quote:
Originally posted by ranvir_2k

Hi all,

I'm planning on adding an nvarchar(255) column to an existing table that has 24 million rows. The new column will have null values initially.

The table is 4GB in size.

Is there any way to calculate how much this will cause the transaction log to grow to?



Thanks

It should cause almost no log activity assuming your alter statement is something like this:
ALTER TABLE YourTable ADD YourNewCol NVARCHAR(255) NULL;

On the other hand, if you were to add a non nullable column with a default value, it would result in a lot of log activity corresponding to each row.

There is one possible exception, which is that if adding the new column were to push one or more of the existing columns to row overflow data allocation units. But, on this, I don't know exactly how SQL Server handles it - whether it generates log records or not when it internally moves a column to overflow allocation units.
Go to Top of Page
   

- Advertisement -