if (select count(*) from syscolumn where column_name='LastInvoiceOtchet2' and table_id=(select table_id from systable where table_name='Counters')) =0 then alter table Counters add LastInvoiceOtchet2 integer not null DEFAULT 0; end if; IF (SELECT LastInvoiceOtchet2 FROM Counters)=0 then update Counters set LastInvoiceOtchet2=(select VaucherInvoiceCounter from Counters)-1; end if GO if (select count(*) from syscolumn where column_name='OtchetType' and table_id=(select table_id from systable where table_name='Otcheti')) =0 then alter table Otcheti Add OtchetType integer default 0; // OtchetType=0 otdelni counters za vtd i hotel, OtchetType=1 obshti; end if GO if (select count(*) from syscolumn where column_name='VtdFromInvoiceNo' and table_id=(select table_id from systable where table_name='Otcheti')) =0 then alter table Otcheti Add VtdFromInvoiceNo integer default Null; end if; GO if (select count(*) from syscolumn where column_name='VtdToInvoiceNo' and table_id=(select table_id from systable where table_name='Otcheti')) =0 then alter table Otcheti Add VtdToInvoiceNo integer default Null; end if;