
/*------ ATD 285317 ------*/
IF NOT EXISTS (SELECT 1 FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'ITNFSAICOMPLEMENTO' AND COLUMN_NAME = 'CENQIPI') 
   ALTER TABLE ITNFSAICOMPLEMENTO ADD CENQIPI CHAR(3)
GO
IF NOT EXISTS (SELECT 1 FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'ITNFENTCOMPLEMENTO' AND COLUMN_NAME = 'CENQIPI') 
   ALTER TABLE ITNFENTCOMPLEMENTO ADD CENQIPI CHAR(3)
GO
IF NOT EXISTS (SELECT 1 FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'DADOSITEMNFE' AND COLUMN_NAME = 'CENQIPI') 
   ALTER TABLE DADOSITEMNFE ADD CENQIPI CHAR(3)
GO
IF NOT EXISTS (SELECT 1 FROM SYSOBJECTS WHERE xtype='U' AND name='CodigoEnqIpi') 
BEGIN
create table CodigoEnqIpi (
       CODIGO CHAR(3) NOT NULL,
       GRUPOCST VARCHAR(100),
       DESCRICAO VARCHAR(500))
alter table CodigoEnqIpi ADD CONSTRAINT PK_CodigoEnqIpi PRIMARY KEY CLUSTERED(CODIGO)
END
GO
