if exists
(
	select * from sys.indexes i where i.object_id = object_id('AKUZ.T_CARD_NOTE', 'U') and i.name = 'IX_T_CARD_NOTE_AmbulanceCardRecord'
)
	DROP INDEX IX_T_CARD_NOTE_AmbulanceCardRecord ON AKUZ.T_CARD_NOTE;
go
CREATE INDEX IX_T_CARD_NOTE_AmbulanceCardRecord ON AKUZ.T_CARD_NOTE(AmbulanceCardRecord) INCLUDE (DocumentNumber, Name, Deleted) WITH (FILLFACTOR=100);
go

IF  EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[AKUZ].[T_CARD_NOTE]') AND name = N'IX_T_CARD_NOTE_CdaDocument')
DROP INDEX [IX_T_CARD_NOTE_CdaDocument] ON [AKUZ].[T_CARD_NOTE]
GO
CREATE NONCLUSTERED INDEX [IX_T_CARD_NOTE_CdaDocument] ON [AKUZ].[T_CARD_NOTE]
(
	[CdaDocument] ASC
)WITH (PAD_INDEX = OFF) ON [PRIMARY]
GO

if exists(select* from sys.indexes i where i.[object_id] = object_id('AKUZ.T_CARD_NOTE', 'U') and i.name = 'IX_T_CARD_NOTE_Registered')
	DROP INDEX IX_T_CARD_NOTE_Registered ON AKUZ.T_CARD_NOTE;
GO
CREATE INDEX IX_T_CARD_NOTE_Registered ON AKUZ.T_CARD_NOTE(Registered, EmdrDocType) INCLUDE(WhereToSend, AmbulanceCardRecord) WITH (FILLFACTOR=100);
GO