Skip to content
Advertisement

add not null column take values from other column

I have an existing table say, Items with Id | CreateDate (as DateTime) columns; want to add Year int not null, take the default year from the CreateDate column.

The Year value will be futer updated to different value, but just set it as default value when the column Year is added, because want to add non-nullable column to Year.

Is that possible?

Advertisement

Answer

If you want to add a new column and initialize it with the values from the other one, you can do:

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement