There are 2 different ways to address this problem.Both adds a default value but adds a totally different meaning to the problem statement here.
Lets 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
1.Add Columns with Default Value for Future Inserts
ALTER TABLE ExistingTableADD ColWithDefault VARCHAR(10) DEFAULT 'Hi'GO
So now as we have added a default column when we are inserting a new record it will default it's value to 'Hi'
if value not provided
INSERT INTO ExistingTable(ID)VALUES (4)GOSelect * from ExistingTableGO
Well this addresses our problem to have default value but here is a catch to the problem.What if we want to have 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
The following script will add a new column with a default value in every possible scenario.
Hope it adds value to the question asked.Thanks.