﻿--Migration
IF EXISTS (SELECT 1 FROM sys.indexes WHERE name = 'NCI_20180403') BEGIN
  DROP INDEX NCI_20180403 ON T_TANULOMULASZTAS
END
GO

IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = 'IX_TANULOMULASZTAS_ORATANULOIID_TANITASIORAKID_TIPUS_INTEZMENYID_TANEVID') BEGIN
  CREATE NONCLUSTERED INDEX IX_TANULOMULASZTAS_ORATANULOIID_TANITASIORAKID_TIPUS_INTEZMENYID_TANEVID 
    ON dbo.T_TANULOMULASZTAS (
    	C_ORATANULOIID ASC,
    	C_TANITASIORAKID ASC,
    	C_TIPUS ASC,
    	C_INTEZMENYID ASC,
    	C_TANEVID ASC
    ) 
  WHERE ([TOROLT]='F')
END  
GO

IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = 'IX_ORARENDIORA_ORARENDIORAGROUPID_ORAERVENYESSEGKEZDETE_TANEVID_INTEZMENYID') BEGIN
  CREATE NONCLUSTERED INDEX IX_ORARENDIORA_ORARENDIORAGROUPID_ORAERVENYESSEGKEZDETE_TANEVID_INTEZMENYID
    ON T_ORARENDIORA (
      C_ORARENDIORAGROUPID, 
      C_ORAERVENYESSEGKEZDETE, 
      C_TANEVID, 
      C_INTEZMENYID
    ) 
  INCLUDE(C_ORAERVENYESSEGVEGE) 
  WHERE TOROLT = 'F'
END
GO

IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = 'IX_TANTARGYID_OSZTALYCSOPORTID_INTEZMENYID_TANEVID_ORASZAM') BEGIN
  CREATE NONCLUSTERED INDEX IX_TANTARGYID_OSZTALYCSOPORTID_INTEZMENYID_TANEVID_ORASZAM 
    ON T_TANMENET (
      C_TANTARGYID, 
      C_OSZTALYCSOPORTID, 
      C_INTEZMENYID, 
      C_TANEVID, 
      C_ORASZAM
    ) 
  WHERE TOROLT = 'F'	
END
GO
