Let’s say there’s a table in SQL Server 2008 with two columns: id and name. Now let’s say you want to add a non-nullable column to the table called “description”, and in the process of adding this column, you want to use the data in name as the original batch of data in description. Is there not a way to do this directly, i.e., without dropping the table and re-creating it or filling in the values manually post-addition or something? If there is a way, how? Thanks!
Share
You could what you’re asking as a computed column, but then you wouldn’t be able to later modify the description independently.
What you can do to minimize the impact on the log etc. is to add it as nullable, then update the values in batches, then change it to not nullable.
Or as Dems suggested, add it as not nullable with a default value, then later remove the default constraint.