/**Begin C:\PDM_UPGRADE\PDM1\PUR_table.sql **/
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PUR_INQUIRYENTRY' AND KSQL_COL_NAME IN ('FMATERIALNAMETEXT')) 
 ALTER TABLE T_PUR_INQUIRYENTRY ADD (FMATERIALNAMETEXT NVARCHAR(255) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PUR_INQUIRYENTRY' AND KSQL_COL_NAME IN ('FLINETYPEID')) 
 ALTER TABLE T_PUR_INQUIRYENTRY ADD (FLINETYPEID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PUR_COMPARE' AND KSQL_COL_NAME IN ('FBUSINESSTYPEID')) 
 ALTER TABLE T_PUR_COMPARE ADD (FBUSINESSTYPEID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PUR_BIDBILLQUOTE' AND KSQL_COL_NAME IN ('FMATERIALNAMETEXT')) 
 ALTER TABLE T_PUR_BIDBILLQUOTE ADD (FMATERIALNAMETEXT NVARCHAR(255) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PUR_BIDBILLENTRY' AND KSQL_COL_NAME IN ('FMATERIALNAMETEXT')) 
 ALTER TABLE T_PUR_BIDBILLENTRY ADD (FMATERIALNAMETEXT NVARCHAR(255) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PUR_BIDBILLENTRY' AND KSQL_COL_NAME IN ('FLINETYPEID')) 
 ALTER TABLE T_PUR_BIDBILLENTRY ADD (FLINETYPEID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PUR_INQUIRY' AND KSQL_COL_NAME IN ('FBUSINESSTYPEID')) 
 ALTER TABLE T_PUR_INQUIRY ADD (FBUSINESSTYPEID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PUR_QUOTE' AND KSQL_COL_NAME IN ('FBUSINESSTYPEID')) 
 ALTER TABLE T_PUR_QUOTE ADD (FBUSINESSTYPEID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PUR_QUOTENTRY' AND KSQL_COL_NAME IN ('FMATERIALNAMETEXT')) 
 ALTER TABLE T_PUR_QUOTENTRY ADD (FMATERIALNAMETEXT NVARCHAR(255) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PUR_QUOTENTRY' AND KSQL_COL_NAME IN ('FLINETYPEID')) 
 ALTER TABLE T_PUR_QUOTENTRY ADD (FLINETYPEID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PUR_COMPARENTRY' AND KSQL_COL_NAME IN ('FMATERIALNAMETEXT')) 
 ALTER TABLE T_PUR_COMPARENTRY ADD (FMATERIALNAMETEXT NVARCHAR(255) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PUR_COMPARENTRY' AND KSQL_COL_NAME IN ('FLINETYPEID')) 
 ALTER TABLE T_PUR_COMPARENTRY ADD (FLINETYPEID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PUR_BIDBILL' AND KSQL_COL_NAME IN ('FBUSINESSTYPEID')) 
 ALTER TABLE T_PUR_BIDBILL ADD (FBUSINESSTYPEID BIGINT DEFAULT 0 NOT NULL );
 
 EXEC p_AlterColumn 'T_PUR_INQUIRY', 'FBILLTYPEID', 'BIGINT', 'NOT NULL', '0001', '1270375173299638272';


 EXEC p_AlterColumn 'T_PUR_BIDBILL', 'FBILLTYPEID', 'BIGINT', 'NOT NULL', '0001', '1270377872653029376';


/**End C:\PDM_UPGRADE\PDM1\PUR_table.sql **/
