
IF EXISTS(SELECT [NAME] FROM SYS.tables WHERE [NAME]='HSAGBILGI')
BEGIN
    IF EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[HSAGBILGI]') AND name = N'IX_HSAGBILGI_HKIMLIKID')
    BEGIN
	   CREATE UNIQUE NONCLUSTERED INDEX [IX_HSAGBILGI_HKIMLIKID] ON [dbo].[HSAGBILGI]
	   (
		   [HKIMLIKID] ASC
	   )
	   INCLUDE
	   (
		  [ENGELLILIK]
	   )
	   WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = ON, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, FILLFACTOR = 90) ON [PRIMARY]
    END
    ELSE
    BEGIN
    	   CREATE UNIQUE NONCLUSTERED INDEX [IX_HSAGBILGI_HKIMLIKID] ON [dbo].[HSAGBILGI]
	   (
		   [HKIMLIKID] ASC
	   )
	   INCLUDE
	   (
		  [ENGELLILIK]
	   )
	   WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, FILLFACTOR = 90) ON [PRIMARY]
    END
END
