
/*------ ATD 280196 ------*/
IF NOT EXISTS (SELECT 1 FROM SYSCOLUMNS WHERE name = 'FILIAL' and syscolumns.id IN (SELECT ID FROM SYSOBJECTS WHERE xtype='U' AND name='AliqCreditoICMS'))
	ALTER TABLE AliqCreditoICMS ADD FILIAL CHAR(2) DEFAULT ''
GO

IF EXISTS (SELECT 1 FROM SYSCOLUMNS WHERE name = 'FILIAL' and syscolumns.id IN (SELECT ID FROM SYSOBJECTS WHERE xtype='U' AND name='AliqCreditoICMS'))
	UPDATE ALIQCREDITOICMS set filial = '' where filial is null
GO

IF  EXISTS (SELECT c.CONSTRAINT_NAME
FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS AS c
WHERE CONSTRAINT_TYPE = 'PRIMARY KEY' and c.table_name ='ALIQCREDITOICMS')
ALTER TABLE ALIQCREDITOICMS DROP CONSTRAINT PK_ALIQCREDITOICMS