How do I add a column, with a default value, to an existing table in SQLServer 2008?
Asked
Active
Viewed 4.1k times
2 Answers
20
ALTER TABLE {TABLENAME}
ADD {COLUMNNAME} {TYPE} {NULL|NOT NULL}
CONSTRAINT {CONSTRAINT_NAME} DEFAULT {DEFAULT_VALUE}
Add a column with a default value to an existing table in SQL Server

Pritesh Tayade
- 630
- 4
- 11
9

peterm
- 91,357
- 15
- 148
- 157
-
2As a general rule, it is best to name your constraints. If you don't it will get a random name, and they will differ between different databases (eg at different client installations). This will make scripting changes difficult in some cases (ie you will have to resort to workarounds). – TT. Jun 05 '13 at 06:22
-
1@TT. Fair point. Agreed. – peterm Jun 05 '13 at 07:47