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

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


 EXEC P_ALTERPK 'PK_T_SM_XSALORDERDELIVENTRY', 'T_SM_XSALORDERDELIVENTRY', 'FDETAILID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_SM_XORDERDELIENTRY_FEID') CREATE INDEX IDX_SM_XORDERDELIENTRY_FEID ON T_SM_XSALORDERDELIVENTRY ( FENTRYID );


 EXEC P_ALTERPK 'PK_T_SM_XSALORDERTERMENTRY', 'T_SM_XSALORDERTERMENTRY', 'FENTRYID', '1';

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


 EXEC P_ALTERPK 'PK_T_SM_XSALORDERENTRY', 'T_SM_XSALORDERENTRY', 'FENTRYID', '1';

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


 EXEC P_ALTERPK 'PK_T_SM_XSALORDERENTRY_R', 'T_SM_XSALORDERENTRY_R', 'FENTRYID', '1';

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


 EXEC P_ALTERPK 'PK_T_SM_XSALORDERLOG', 'T_SM_XSALORDERLOG', 'FID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_SM_XSALORDERLOG_BILLNO') CREATE INDEX IDX_SM_XSALORDERLOG_BILLNO ON T_SM_XSALORDERLOG ( FXBILLNO );


 EXEC P_ALTERPK 'PK_T_SM_XSALORDER_C', 'T_SM_XSALORDER_C', 'FID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_SM_XSALESORDER_C_CUSID') CREATE INDEX IDX_SM_XSALESORDER_C_CUSID ON T_SM_XSALORDER_C ( FCUSTOMERID );


 EXEC P_ALTERPK 'PK_T_SM_XSALORDER_F', 'T_SM_XSALORDER_F', 'FID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_SM_XSALEORDER_F_SETTLE') CREATE INDEX IDX_SM_XSALEORDER_F_SETTLE ON T_SM_XSALORDER_F ( FSETTLETYPEID ,FSETTLEORGID );


 EXEC P_ALTERPK 'PK_T_SM_XSALORDERENTRY_F', 'T_SM_XSALORDERENTRY_F', 'FENTRYID', '1';

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


 EXEC P_ALTERPK 'PK_T_SM_XSALORDERRPENTRY', 'T_SM_XSALORDERRPENTRY', 'FENTRYID', '1';

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


 EXEC P_ALTERPK 'PK_T_SM_XSALORDERTRACEENTRY', 'T_SM_XSALORDERTRACEENTRY', 'FENTRYID', '1';

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


 EXEC P_ALTERPK 'PK_T_SM_XSALORDER_L', 'T_SM_XSALORDER_L', 'FPKID', '1';

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



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