/**Begin E:\NextERP_PDM\PDM_UPGRADE\PDMS\branch_lastest\pdm\SBD_constraint.sql **/
 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_BD_SNMOVETRACK_BILLENTRY') CREATE INDEX IDX_BD_SNMOVETRACK_BILLENTRY ON T_BD_SNMOVETRACK ( FBILLENTRYID );

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_BD_SNMOVETRACK_KW') CREATE INDEX IDX_BD_SNMOVETRACK_KW ON T_BD_SNMOVETRACK ( FKEEPORGID ,FWAREHOUSEID );

 EXEC P_ALTERPK 'PK_T_BD_SNDIMENSIONENTRY', 'T_BD_SNDIMENSIONENTRY', 'FENTRYID', '1';

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

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_BD_SNDIMENSIONENTRY_ST') CREATE INDEX IDX_BD_SNDIMENSIONENTRY_ST ON T_BD_SNDIMENSIONENTRY ( FSNDIMITEM );

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_BD_SNDIMENSIONENTRY_SN') CREATE INDEX IDX_BD_SNDIMENSIONENTRY_SN ON T_BD_SNDIMENSIONENTRY ( FSNDIMNUMBER );


 EXEC P_ALTERPK 'PK_T_BD_SNMOVETRACK_REL', 'T_BD_SNMOVETRACK_REL', 'FID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_BD_SNMOVETRACKREL_TRACK') CREATE INDEX IDX_BD_SNMOVETRACKREL_TRACK ON T_BD_SNMOVETRACK_REL ( FTRACKID );

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_BD_SNMOVETRACKREL_SMF') CREATE INDEX IDX_BD_SNMOVETRACKREL_SMF ON T_BD_SNMOVETRACK_REL ( FSNMAINFILEID );


 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_BD_SNMAINFILE_OCCUPYBILLID') CREATE INDEX IDX_BD_SNMAINFILE_OCCUPYBILLID ON T_BD_SNMAINFILE ( FOCCUPYBILLID );

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_BD_SNMAINFILE_FTRA') CREATE INDEX IDX_BD_SNMAINFILE_FTRA ON T_BD_SNMAINFILE ( FFINALAUDITTRAILID );

 EXEC P_ALTERPK 'PK_T_BD_SNDIMENSION_L', 'T_BD_SNDIMENSION_L', 'FPKID', '1';

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


 EXEC P_ALTERPK 'PK_T_BD_SNDIMENSION', 'T_BD_SNDIMENSION', 'FID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_BD_SNDIMENSION') CREATE INDEX IDX_BD_SNDIMENSION ON T_BD_SNDIMENSION ( FNUMBER );



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