/**Begin E:\NextERP_PDM\PDM_UPGRADE\PDMS\branch_lastest\pdm\SM_constraint.sql **/
 EXEC P_ALTERPK 'PK_T_SM_SALSAGENCY', 'T_SM_SALSAGENCY', 'FID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_SM_SALESAGENCY_FBILLNO') CREATE INDEX IDX_SM_SALESAGENCY_FBILLNO ON T_SM_SALSAGENCY ( FBILLNO  DESC );

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_SM_SALESAGENCY_FORGID') CREATE INDEX IDX_SM_SALESAGENCY_FORGID ON T_SM_SALSAGENCY ( FORGID ,FBIZDATE  DESC ,FBILLNO  DESC ,FID );

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_SM_SALESAGENCY_FBIZDATE') CREATE INDEX IDX_SM_SALESAGENCY_FBIZDATE ON T_SM_SALSAGENCY ( FBIZDATE  DESC );


 EXEC P_ALTERPK 'PK_T_SM_SALSAGENCY_L', 'T_SM_SALSAGENCY_L', 'FPKID', '1';

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


 EXEC P_ALTERPK 'PK_T_SM_SALSAGENCYENTRY', 'T_SM_SALSAGENCYENTRY', 'FENTRYID', '1';

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

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_SM_SALESE_MATID') CREATE INDEX IDX_SM_SALESE_MATID ON T_SM_SALSAGENCYENTRY ( FMATERIALID ,FID );

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_SM_SALESE_MATMASTERID') CREATE INDEX IDX_SM_SALESE_MATMASTERID ON T_SM_SALSAGENCYENTRY ( FMATERIALMASTERID ,FID );



/**End E:\NextERP_PDM\PDM_UPGRADE\PDMS\branch_lastest\pdm\SM_constraint.sql **/
