
IF   EXISTS (  SELECT * 
				 FROM INFORMATION_SCHEMA.COLUMNS  
				WHERE TABLE_NAME  = 'BC_CONCILICAO_BCO_RETORNO' 
				  AND COLUMN_NAME  = 'CD_CNT' 
				  AND IS_NULLABLE  = 'YES'
				 ) 
BEGIN 
	ALTER TABLE BC_CONCILICAO_BCO_RETORNO ALTER COLUMN CD_CNT INT NOT NULL 
END 
GO

IF NOT EXISTS (SELECT   * 
				 FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE 
				WHERE CONSTRAINT_NAME  = 'PK_BC_CONCILICAO_BCO_RETORNO' 
				  AND COLUMN_NAME  = 'CD_CNT' 
				 ) 
BEGIN 
	
	ALTER TABLE BC_CONCILICAO_BCO_RETORNO DROP CONSTRAINT PK_BC_CONCILICAO_BCO_RETORNO
	ALTER TABLE BC_CONCILICAO_BCO_RETORNO ADD CONSTRAINT PK_BC_CONCILICAO_BCO_RETORNO PRIMARY KEY (NR_LOTE, CD_BC, DT_GER_ARQ, SEQ_ARQ,  CD_CNT)

END 