if (select count(*) from sys.syscolumns where tname='SpaCounters' and cname='SpaMedOfficeCounter')=0 then alter table SpaCounters Add SpaMedOfficeCounter integer default 0 end if GO update SpaCounters Set SpaMedOfficeCounter=IsNull((select Max(N) from SpaMedicalOffices),0) GO if (select count(*) from sys.syscolumns where tname='SpaCounters' and cname='SpaWorkersCounter')=0 then alter table SpaCounters Add SpaWorkersCounter integer default 0 end if GO update SpaCounters Set SpaWorkersCounter= IsNull((select Max(N) from SpaWorkers),0) GO if (select count(*) from sys.syscolumns where tname='SpaWorkers' and cname='Status')=1 then alter table SpaWorkers delete Status end if GO if (select count(*) from sys.syscolumns where tname='SpaWorkers' and cname='Active')=0 then alter table SpaWorkers Add Active integer default 0 end if GO update SpaWorkers Set Active=1 where Active is null