if exists(select * from sys.indexes i where i.[object_id] = OBJECT_ID('AKUZ.T_SCHET_SLUCH', 'U') and i.name = 'IX_T_SCHET_SLUCH_SchetSluchCorr')
	drop index IX_T_SCHET_SLUCH_SchetSluchCorr on AKUZ.T_SCHET_SLUCH;
go
CREATE INDEX IX_T_SCHET_SLUCH_SchetSluchCorr ON AKUZ.T_SCHET_SLUCH(SchetSluchCorr) INCLUDE (IDDOKT, SchetZSl) WITH (FILLFACTOR=95, SORT_IN_TEMPDB=ON);
go

if exists(select * from sys.indexes i where i.[object_id] = OBJECT_ID('AKUZ.T_SCHET_SLUCH', 'U') and i.name = 'IX_T_SCHET_SLUCH_DATE_1')
	drop index IX_T_SCHET_SLUCH_DATE_1 on AKUZ.T_SCHET_SLUCH;
go
CREATE INDEX IX_T_SCHET_SLUCH_DATE_1 ON AKUZ.T_SCHET_SLUCH(DATE_1, DATE_2)  INCLUDE (SchetZap) WITH (FILLFACTOR=95, SORT_IN_TEMPDB=ON);
go

if exists(select * from sys.indexes i where i.[object_id] = OBJECT_ID('AKUZ.T_SCHET_SLUCH', 'U') and i.name = 'IX_T_SCHET_SLUCH_NHISTORY')
	drop index IX_T_SCHET_SLUCH_NHISTORY on AKUZ.T_SCHET_SLUCH;
go
CREATE INDEX [IX_T_SCHET_SLUCH_NHISTORY]  ON [AKUZ].[T_SCHET_SLUCH] ([NHISTORY])  INCLUDE ([SchetZap])  WHERE [NHISTORY] IS NOT NULL WITH (FILLFACTOR=95, SORT_IN_TEMPDB=ON);