/**Begin E:\NextERP_PDM\PDM_UPGRADE\PDMS\branch_lastest\pdm\IM_table.sql **/
-- 转换单，仓位移动单增加来源单据实体，来源单据id，来源单据分录id三个字段
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_ADJUSTBILLENTRY' AND KSQL_COL_NAME ='FSRCBILLENTITY') 
 ALTER TABLE T_IM_ADJUSTBILLENTRY ADD (FSRCBILLENTITY NVARCHAR(50) DEFAULT ' ' NOT NULL);
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_ADJUSTBILLENTRY' AND KSQL_COL_NAME ='FSRCBILLID') 
 ALTER TABLE T_IM_ADJUSTBILLENTRY ADD (FSRCBILLID BIGINT DEFAULT 0 NOT NULL);
 IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_ADJUSTBILLENTRY' AND KSQL_COL_NAME ='FSRCBILLENTRYID') 
 ALTER TABLE T_IM_ADJUSTBILLENTRY ADD (FSRCBILLENTRYID BIGINT DEFAULT 0 NOT NULL);
 
 IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_DISASSEMBLEENTRY' AND KSQL_COL_NAME ='FSRCBILLENTITY') 
 ALTER TABLE T_IM_DISASSEMBLEENTRY ADD (FSRCBILLENTITY NVARCHAR(50) DEFAULT ' ' NOT NULL);
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_DISASSEMBLEENTRY' AND KSQL_COL_NAME ='FSRCBILLID') 
 ALTER TABLE T_IM_DISASSEMBLEENTRY ADD (FSRCBILLID BIGINT DEFAULT 0 NOT NULL);
 IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_DISASSEMBLEENTRY' AND KSQL_COL_NAME ='FSRCBILLENTRYID') 
 ALTER TABLE T_IM_DISASSEMBLEENTRY ADD (FSRCBILLENTRYID BIGINT DEFAULT 0 NOT NULL);
 
  IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_ASSEMBBILLENTRY' AND KSQL_COL_NAME ='FSRCBILLENTITY') 
 ALTER TABLE T_IM_ASSEMBBILLENTRY ADD (FSRCBILLENTITY NVARCHAR(50) DEFAULT ' ' NOT NULL);
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_ASSEMBBILLENTRY' AND KSQL_COL_NAME ='FSRCBILLID') 
 ALTER TABLE T_IM_ASSEMBBILLENTRY ADD (FSRCBILLID BIGINT DEFAULT 0 NOT NULL);
 IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_ASSEMBBILLENTRY' AND KSQL_COL_NAME ='FSRCBILLENTRYID') 
 ALTER TABLE T_IM_ASSEMBBILLENTRY ADD (FSRCBILLENTRYID BIGINT DEFAULT 0 NOT NULL);
  
  IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_LOCATIONTRANSENTRY' AND KSQL_COL_NAME ='FSRCBILLENTITY') 
 ALTER TABLE T_IM_LOCATIONTRANSENTRY ADD (FSRCBILLENTITY NVARCHAR(50) DEFAULT ' ' NOT NULL);
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_LOCATIONTRANSENTRY' AND KSQL_COL_NAME ='FSRCBILLID') 
 ALTER TABLE T_IM_LOCATIONTRANSENTRY ADD (FSRCBILLID BIGINT DEFAULT 0 NOT NULL);
 IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_LOCATIONTRANSENTRY' AND KSQL_COL_NAME ='FSRCBILLENTRYID') 
 ALTER TABLE T_IM_LOCATIONTRANSENTRY ADD (FSRCBILLENTRYID BIGINT DEFAULT 0 NOT NULL);
 
 
 
 
 

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