/**Begin C:\PDM_UPGRADE\PDM1\PUR_constraint.sql **/
EXEC p_DropIdx 'IDX_PUR_SUPBIZENTRY_FID_FSeq', 'T_PUR_SUPBIZPERSONENTRY';
 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_PUR_SUPBIZENTRY_FID_FSEQ') CREATE INDEX IDX_PUR_SUPBIZENTRY_FID_FSEQ ON T_PUR_SUPBIZPERSONENTRY ( FSEQ );

EXEC p_DropIdx 'IDX_PUR_CACATEGORY', 'T_PUR_CACATEGORY';
 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_PUR_CACATEGORY') CREATE INDEX IDX_PUR_CACATEGORY ON T_PUR_CACATEGORY ( FCATEGORYID );

EXEC p_DropIdx 'IDX_PUR_CAMEMBER', 'T_PUR_CAMEMBER';
 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_PUR_CAMEMBER') CREATE INDEX IDX_PUR_CAMEMBER ON T_PUR_CAMEMBER ( FMEMBERID );

EXEC p_DropIdx 'IDX_T_PUR_SDH_REF_FID', 'T_PUR_REFSCDATAHANDLE';
 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_T_PUR_SDH_REF_FID') CREATE INDEX IDX_T_PUR_SDH_REF_FID ON T_PUR_REFSCDATAHANDLE ( FSCDATASERVICEID );

EXEC p_DropIdx 'IDX_T_PUR_SDC_REF_FID', 'T_PUR_REFSCDATACONFIG';
 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_T_PUR_SDC_REF_FID') CREATE INDEX IDX_T_PUR_SDC_REF_FID ON T_PUR_REFSCDATACONFIG ( FSCDATACONFIGID );

 EXEC P_ALTERPK 'PK_T_PUR_IMINVENTORY', 'T_PUR_IMINVENTORY', 'FID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_PUR_IMINVENTORY_MATID') CREATE INDEX IDX_PUR_IMINVENTORY_MATID ON T_PUR_IMINVENTORY ( FMATERIALID );

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_PUR_IMINVENTORY_FRECORGID') CREATE INDEX IDX_PUR_IMINVENTORY_FRECORGID ON T_PUR_IMINVENTORY ( FRECORGID );


 EXEC P_ALTERPK 'PK_T_PUR_REPLENISHREQ', 'T_PUR_REPLENISHREQ', 'FID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_PUR_REPLENISHREQ_FBILLNO') CREATE INDEX IDX_PUR_REPLENISHREQ_FBILLNO ON T_PUR_REPLENISHREQ ( FBILLNO );


 EXEC P_ALTERPK 'PK_T_PUR_REPLENISHREQ_L', 'T_PUR_REPLENISHREQ_L', 'FPKID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_PUR_REP_L_FID_FLOCALEID') CREATE INDEX IDX_PUR_REP_L_FID_FLOCALEID ON T_PUR_REPLENISHREQ_L ( FID );


 EXEC P_ALTERPK 'PK_T_PUR_REPLENISHREQENTRY', 'T_PUR_REPLENISHREQENTRY', 'FENTRYID', '0';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_PUR_REP_FMATID') CREATE  CLUSTERED INDEX IDX_PUR_REP_FMATID ON T_PUR_REPLENISHREQENTRY ( FMATERIALID );


 EXEC P_ALTERPK 'PK_T_PUR_CONMATERIAL', 'T_PUR_CONMATERIAL', 'FID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_PUR_ORDER_FID') CREATE INDEX IDX_PUR_ORDER_FID ON T_PUR_CONMATERIAL ( FSUPPLIERID ,FORGID );


 EXEC P_ALTERPK 'PK_T_PUR_CONMATERIAL_L', 'T_PUR_CONMATERIAL_L', 'FPKID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_PUR_CONMATERIAL_L_FID') CREATE INDEX IDX_PUR_CONMATERIAL_L_FID ON T_PUR_CONMATERIAL_L ( FID ,FLOCALEID );


 EXEC P_ALTERPK 'PK_T_PUR_CONMATERIALENTRY', 'T_PUR_CONMATERIALENTRY', 'FENTRYID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_PUR_CONENTRY_FMATERIALID') CREATE INDEX IDX_PUR_CONENTRY_FMATERIALID ON T_PUR_CONMATERIALENTRY ( FMATERIALID );

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_PUR_CONENTRY_FID_FSEQ') CREATE INDEX IDX_PUR_CONENTRY_FID_FSEQ ON T_PUR_CONMATERIALENTRY ( FID ,FSEQ );



/**End C:\PDM_UPGRADE\PDM1\PUR_constraint.sql **/
