USE [EnVisage]
GO

create table ##t([update]  bit null )

if not exists (select * from sys.columns where name='IsSystem' and [object_id] = object_id('WorkWeek'))
insert into ##t values(1)
else
insert into ##t values(0)
go 

if(exists (select 1 from ##t where [update] = 1))
	ALTER TABLE dbo.WorkWeek
	ADD 
		[IsSystem] bit NULL
go

if(exists (select 1 from ##t where [update] = 1))
	UPDATE WorkWeek set IsSystem = 0;
	UPDATE WorkWeek set IsSystem = 1 where Id = (SELECT top 1 Id FROM WorkWeek);
go

ALTER TABLE dbo.WorkWeek
	ALTER COLUMN 
		[IsSystem] bit NOT NULL
GO

drop table ##t
go