There are 2 different ways to address this problem.
Both add a default value but add a totally different meaning to the problem statement here.
Let's start with creating some sample data.
Create Sample Data
CREATE TABLE ExistingTable (ID INT)GOINSERT INTO ExistingTable (ID)VALUES (1), (2), (3)GOSELECT *FROM ExistingTable
Image may be NSFW.
Clik here to view.
1. Add Columns with Default Value for Future Inserts
ALTER TABLE ExistingTableADD ColWithDefault VARCHAR(10) DEFAULT 'Hi'GO
Image may be NSFW.
Clik here to view.
So now, as we have added a default column when we are inserting a new record, it will default its value to 'Hi'
if the value is not provided.
INSERT INTO ExistingTable(ID)VALUES (4)GOSelect * from ExistingTableGO
Image may be NSFW.
Clik here to view.
Well, this addresses our problem to have default value, but here is a catch to the problem.What if we want to have a default value in all the columns, not just the future inserts?
For this, we have Method 2.
2. Add Column with Default Value for ALL Inserts
ALTER TABLE ExistingTableADD DefaultColWithVal VARCHAR(10) DEFAULT 'DefaultAll'WITH VALUESGOSelect * from ExistingTableGO
Image may be NSFW.
Clik here to view.
The following script will add a new column with a default value in every possible scenario.