IF EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[LOG]') AND name = N'IX_LOGS_ISLEM')
BEGIN
    CREATE NONCLUSTERED INDEX [IX_LOGS_ISLEM] ON [dbo].[LOG]
    (
	    [ISLEM] ASC
    )WITH (PAD_INDEX = ON, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = ON, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, FILLFACTOR = 70) ON [PRIMARY]
END
ELSE
BEGIN
    CREATE NONCLUSTERED INDEX [IX_LOGS_ISLEM] ON [dbo].[LOG]
    (
	    [ISLEM] ASC
    )WITH (PAD_INDEX = ON, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, FILLFACTOR = 70) ON [PRIMARY]
END


IF EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[LOG]') AND name = N'IX_LOGS_KAYITNO_LOGID')
BEGIN
    CREATE NONCLUSTERED INDEX [IX_LOGS_KAYITNO_LOGID] ON [dbo].[LOG]
    (
	    [KAYITNO] ASC,
	    [LOGID] ASC
    )WITH (PAD_INDEX = ON, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = ON, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, FILLFACTOR = 70) ON [PRIMARY]
END
ELSE
BEGIN
    CREATE NONCLUSTERED INDEX [IX_LOGS_KAYITNO_LOGID] ON [dbo].[LOG]
    (
	    [KAYITNO] ASC,
	    [LOGID] ASC
    )WITH (PAD_INDEX = ON, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, FILLFACTOR = 70) ON [PRIMARY]
END


IF EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[LOG]') AND name = N'IX_LOGS_TABLE_TARIH_SAAT_LOGID')
BEGIN
    CREATE NONCLUSTERED INDEX [IX_LOGS_TABLE_TARIH_SAAT_LOGID] ON [dbo].[LOG]
    (
	    [TABLE] ASC,
	    [TARIH] ASC,
	    [SAAT] ASC,
	    [LOGID] ASC
    )WITH (PAD_INDEX = ON, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = ON, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, FILLFACTOR = 70) ON [PRIMARY]
END
ELSE
BEGIN
    CREATE NONCLUSTERED INDEX [IX_LOGS_TABLE_TARIH_SAAT_LOGID] ON [dbo].[LOG]
    (
	    [TABLE] ASC,
	    [TARIH] ASC,
	    [SAAT] ASC,
	    [LOGID] ASC
    )WITH (PAD_INDEX = ON, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, FILLFACTOR = 70) ON [PRIMARY]
END

IF EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[LOG]') AND name = N'IX_LOGS_TARIH_SAAT_LOGID')
BEGIN
CREATE NONCLUSTERED INDEX [IX_LOGS_TARIH_SAAT_LOGID] ON [dbo].[LOG]
(
	[TARIH] ASC,
	[SAAT] ASC,
	[LOGID] ASC
)WITH (PAD_INDEX = ON, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = ON, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, FILLFACTOR = 70) ON [PRIMARY]
END
ELSE
BEGIN
CREATE NONCLUSTERED INDEX [IX_LOGS_TARIH_SAAT_LOGID] ON [dbo].[LOG]
(
	[TARIH] ASC,
	[SAAT] ASC,
	[LOGID] ASC
)WITH (PAD_INDEX = ON, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, FILLFACTOR = 70) ON [PRIMARY]
END


IF EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[LOG]') AND name = N'IX_LOGS_USER')
BEGIN
CREATE NONCLUSTERED INDEX [IX_LOGS_USER] ON [dbo].[LOG]
(
	[USER] ASC
)WITH (PAD_INDEX = ON, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = ON, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, FILLFACTOR = 70) ON [PRIMARY]
END
ELSE
BEGIN
CREATE NONCLUSTERED INDEX [IX_LOGS_USER] ON [dbo].[LOG]
(
	[USER] ASC
)WITH (PAD_INDEX = ON, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, FILLFACTOR = 70) ON [PRIMARY]
END

