﻿CREATE TABLE [dbo].[mfr__appointments] (
    [Id]                  BIGINT         NOT NULL,
    [Version]             INT            NOT NULL,
    [State]               NVARCHAR (255) NULL,
    [Type]                NVARCHAR (255) NULL,
    [EndDateTime]         DATETIME       NULL,
    [StartDateTime]       DATETIME       NOT NULL,
    [DrivingDistanceFrom] INT            NULL,
    [DrivingDistanceTo]   INT            NULL,
    [WasReadOnClientSide] BIT            NOT NULL,
    [ContactIds]          VARCHAR (MAX)  NULL,
    [ServiceRequestId]    BIGINT         NOT NULL,
    [ContactId]           BIGINT         NOT NULL,
    [Note]                NVARCHAR (MAX) NULL,
    CONSTRAINT [PK_mfr__appointment] PRIMARY KEY CLUSTERED ([Id] ASC)
);


GO
CREATE NONCLUSTERED INDEX [mfr__appointments__ix2]
    ON [dbo].[mfr__appointments]([State] ASC, [ServiceRequestId] ASC)
    INCLUDE([EndDateTime], [StartDateTime]);


GO
CREATE NONCLUSTERED INDEX [mfr__appointments__ix1]
    ON [dbo].[mfr__appointments]([State] ASC)
    INCLUDE([EndDateTime], [StartDateTime], [ServiceRequestId]);

