SQL - TSQL - AlterTable

To add a default to a column already in the system

1
2
3
4
5
alter table employees
with nocheck
add constraint Employees__ExpInMo__Def
default 0 for ExpInMo
go

To add a foreign key to a column already in the system

1
2
3
4
5
6
7
8
alter table wq_rehab_small__lining
with noCheck
add Constraint wq_rehab_small__Lining__Uses__wq_rehab_small
foreign key (ProjectName)
references wq_rehab_small(ProjectName)
on update cascade
on delete cascade
go