use EnVisage go begin tran delete from PeopleResourceAllocation where WeekEndingDate is null or Quantity is null if exists (select * from sys.indexes where name='UNIQUE_PeopleResourceAllocation' and object_id =OBJECT_ID('PeopleResourceAllocation')) begin alter table PeopleResourceAllocation drop constraint UNIQUE_PeopleResourceAllocation end alter table dbo.PeopleResourceAllocation alter column WeekEndingDate datetime not null alter table dbo.PeopleResourceAllocation alter column Quantity decimal(18,6) not null ALTER TABLE PeopleResourceAllocation ADD CONSTRAINT UNIQUE_PeopleResourceAllocation UNIQUE (ScenarioId,PeopleResourceId,TeamId,ExpenditureCategoryId,WeekEndingDate) commit tran go