IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_FMM_PROJECT_MCC_CUST' AND KSQL_COL_NAME ='FSALECONSTRACT') 
  ALTER TABLE T_FMM_PROJECT_MCC_CUST ADD (FSALECONSTRACT BIGINT DEFAULT 0 NOT NULL);
  
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_FMM_PROJECT_MCC_CUST' AND KSQL_COL_NAME ='FSALEORDER') 
  ALTER TABLE T_FMM_PROJECT_MCC_CUST ADD (FSALEORDER BIGINT DEFAULT 0 NOT NULL);
  
  
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_FMM_PROJECT_SOURCE')
CREATE TABLE T_FMM_PROJECT_SOURCE
(
	FENTRYID         		        BIGINT                     DEFAULT 0   NOT NULL, 
	FID       				        BIGINT                     DEFAULT 0   NOT NULL, 
	FSEQ       					    INT                        DEFAULT 0   NOT NULL, 
	FSOURCEBILLTYPE			        NVARCHAR(50)               DEFAULT ' ' NOT NULL,
	FSOURCEBILLNO			        NVARCHAR(50)               DEFAULT ' ' NOT NULL
);

EXEC P_ALTERPK 'PK_FMM_PROJECT_SOURCE', 'T_FMM_PROJECT_SOURCE', 'FENTRYID', '1'; 
 
IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_FMM_PROJECT_MCC_CUST_FS') CREATE INDEX IDX_FMM_PROJECT_MCC_CUST_FS ON T_FMM_PROJECT_SOURCE ( FID, FSEQ );
 
  



