IF EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[BIRIMSAYAC]'))
BEGIN
	IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[BIRIMSAYAC]') AND name = N'IX_BIRIMSAYAC_BIRIMID')
	BEGIN
		CREATE NONCLUSTERED INDEX [IX_BIRIMSAYAC_BIRIMID] ON [dbo].[BIRIMSAYAC]
		(
			[BIRIMID] ASC
		)
		INCLUDE ( 	[TARIH],
			[ISLEMSIRANOSAYAC]) WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, FILLFACTOR = 90) ON [PRIMARY]
	END
	ELSE
	BEGIN
		CREATE NONCLUSTERED INDEX [IX_BIRIMSAYAC_BIRIMID] ON [dbo].[BIRIMSAYAC]
		(
			[BIRIMID] ASC
		)
		INCLUDE ( 	[TARIH],
			[ISLEMSIRANOSAYAC]) WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = ON, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, FILLFACTOR = 90) ON [PRIMARY]
	END

END
GO

IF EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[HMUAYENEKDGEBELIK]'))
BEGIN
	IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[HMUAYENEKDGEBELIK]') AND name = N'IX_HMUAYENEKDGEBELIK_HKIMLIKID_SUBEID')
	BEGIN
		CREATE NONCLUSTERED INDEX [IX_HMUAYENEKDGEBELIK_HKIMLIKID_SUBEID]
		ON [dbo].[HMUAYENEKDGEBELIK] ([HKIMLIKID],[SUBEID])
	END
	ELSE
	BEGIN
		CREATE NONCLUSTERED INDEX [IX_HMUAYENEKDGEBELIK_HKIMLIKID_SUBEID]
		ON [dbo].[HMUAYENEKDGEBELIK] ([HKIMLIKID],[SUBEID]) WITH (DROP_EXISTING = ON) ON [PRIMARY]
	END
END
GO

IF EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[HRANDEVUFTR]'))
BEGIN
	IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[HRANDEVUFTR]') AND name = N'IX_HRANDEVUFTR_HRAPORID_RANDDURUMID')
	BEGIN
		CREATE NONCLUSTERED INDEX [IX_HRANDEVUFTR_HRAPORID_RANDDURUMID] ON [dbo].[HRANDEVUFTR]
		(
			[HRAPORID] ASC,
			[RANDDURUMID] ASC
		)
	END
	ELSE
	BEGIN
		CREATE NONCLUSTERED INDEX [IX_HRANDEVUFTR_HRAPORID_RANDDURUMID] ON [dbo].[HRANDEVUFTR]
		(
			[HRAPORID] ASC,
			[RANDDURUMID] ASC
		) WITH (DROP_EXISTING = ON) ON [PRIMARY]
	END
END
GO

IF EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[HBELGE]'))
BEGIN
	IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[HBELGE]') AND name = N'IX_HBELGE_HKIMLIKID')
	BEGIN
		CREATE NONCLUSTERED INDEX [IX_HBELGE_HKIMLIKID]
		ON [dbo].[HBELGE] ([HKIMLIKID])
	END
	ELSE
	BEGIN
		CREATE NONCLUSTERED INDEX [IX_HBELGE_HKIMLIKID]
		ON [dbo].[HBELGE] ([HKIMLIKID])  WITH (DROP_EXISTING = ON) ON [PRIMARY]
	END
END
GO

IF EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[HBELGE]'))
BEGIN
	IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[HBELGE]') AND name = N'IX_HBELGE_HDOSYAID')
	BEGIN
		CREATE NONCLUSTERED INDEX [IX_HBELGE_HDOSYAID] ON [dbo].[HBELGE]
		(
			[HDOSYAID] ASC
		)
	END
	ELSE
	BEGIN
		CREATE NONCLUSTERED INDEX [IX_HBELGE_HDOSYAID] ON [dbo].[HBELGE]
		(
			[HDOSYAID] ASC
		)  WITH (DROP_EXISTING = ON) ON [PRIMARY]
	END

END
GO

IF EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[HKIZLEM]'))
BEGIN
	IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[HKIZLEM]') AND name = N'IX_HKIZLEM_HMUAYENEID')
	BEGIN
		CREATE NONCLUSTERED INDEX [IX_HKIZLEM_HMUAYENEID]
		ON [dbo].[HKIZLEM] ([HMUAYENEID])
	END
	ELSE
	BEGIN
		CREATE NONCLUSTERED INDEX [IX_HKIZLEM_HMUAYENEID]
		ON [dbo].[HKIZLEM] ([HMUAYENEID]) WITH (DROP_EXISTING = ON) ON [PRIMARY]
	END
END
GO

IF EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[STOKSUBE]'))
BEGIN
	IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[STOKSUBE]') AND name = N'IX_STOKSUBE_STOKID_SUBEID')
	BEGIN
		CREATE UNIQUE NONCLUSTERED INDEX [IX_STOKSUBE_STOKID_SUBEID] ON [dbo].[STOKSUBE]
		(
			[STOKID] ASC,
			[SUBEID] ASC
		)
		INCLUDE ( 	[SERIBARKODKULLANILIR],SANADEPOID)
	END
	ELSE
	BEGIN
		CREATE UNIQUE NONCLUSTERED INDEX [IX_STOKSUBE_STOKID_SUBEID] ON [dbo].[STOKSUBE]
		(
			[STOKID] ASC,
			[SUBEID] ASC
		)
		INCLUDE ( 	[SERIBARKODKULLANILIR],SANADEPOID)  WITH (DROP_EXISTING = ON) ON [PRIMARY]
	END
END
GO

IF EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[HRAPORDR]'))
BEGIN
	IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[HRAPORDR]') AND name = N'IX_HRAPORDR_DRBRANSKODU_RAPORUISTEYEN')
	BEGIN
		CREATE NONCLUSTERED INDEX [IX_HRAPORDR_DRBRANSKODU_RAPORUISTEYEN] ON [dbo].[HRAPORDR]
		(
			[DRBRANSKODU],[RAPORUISTEYEN]
		)
		INCLUDE ([HRAPORID]) WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, FILLFACTOR = 90) ON [PRIMARY]
	END
	ELSE
	BEGIN
		CREATE NONCLUSTERED INDEX [IX_HRAPORDR_DRBRANSKODU_RAPORUISTEYEN] ON [dbo].[HRAPORDR]
		(
			[DRBRANSKODU],[RAPORUISTEYEN]
		)
		INCLUDE ([HRAPORID]) WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = ON, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, FILLFACTOR = 90) ON [PRIMARY]
	END
END
GO