Skip to main content

Ajuste impressão NF-E no SQL server

Caso aconteça seguinte problema segue imagem.

image-1712674235761.png



Realize o backup da base de dados em SQL e em seguida feche o sistema e execute  a seguinte SQL.

GO
DROP TABLE TMPFaturamento_NotaFiscal;
GO
DROP TABLE TMPFaturamento_NotaFiscal_EnderecoEntrega;
GO
DROP TABLE TMPFaturamento_NotaFiscal_EnderecoRetirada;
GO
DROP TABLE TMPFaturamento_NotaFiscal_Vencimento;
GO
DROP TABLE TMPFaturamento_NotaFiscal_movimento;
GO


GO
SELECT * INTO TMPFaturamento_NotaFiscal FROM Faturamento_NotaFiscal where Faturamento_NotaFiscal.Código = 0;
GO
SELECT * INTO TMPFaturamento_NotaFiscal_movimento FROM Faturamento_NotaFiscal_movimento;
GO
SELECT * INTO TMPFaturamento_NotaFiscal_Vencimento FROM Faturamento_NotaFiscal_Vencimento;
GO
SELECT * INTO TMPFaturamento_NotaFiscal_EnderecoEntrega FROM Faturamento_NotaFiscal_EnderecoEntrega;
GO
SELECT * INTO TMPFaturamento_NotaFiscal_EnderecoRetirada FROM Faturamento_NotaFiscal_EnderecoRetirada;
GO

GO
DELETE FROM TMPFaturamento_NotaFiscal;
GO
DELETE FROM TMPFaturamento_NotaFiscal_movimento;
GO
DELETE FROM TMPFaturamento_NotaFiscal_Vencimento;
GO
DELETE FROM TMPFaturamento_NotaFiscal_EnderecoEntrega;
GO
DELETE FROM TMPFaturamento_NotaFiscal_EnderecoRetirada;
GO
GO
ALTER TABLE TMPFaturamento_NotaFiscal ADD Criacao date default getdate();
GO
ALTER TABLE TMPFaturamento_NotaFiscal_movimento ADD Criacao date default getdate();
GO
ALTER TABLE TMPFaturamento_NotaFiscal_Vencimento ADD Criacao date default getdate();
GO
ALTER TABLE TMPFaturamento_NotaFiscal_EnderecoEntrega ADD Criacao date default getdate();
GO
ALTER TABLE TMPFaturamento_NotaFiscal_EnderecoRetirada ADD Criacao date default getdate();
GO

GO
ALTER TABLE TMPFaturamento_NotaFiscal_movimento DROP COLUMN Codigo
GO
ALTER TABLE TMPFaturamento_NotaFiscal_movimento ADD Codigo integer default 0
GO

GO
ALTER TABLE TMPFaturamento_NotaFiscal ADD CONSTRAINT PrimaryKey PRIMARY KEY (Código);
GO
ALTER TABLE TMPFaturamento_NotaFiscal_movimento ADD CONSTRAINT PrimaryKey PRIMARY KEY (Codigo);
GO
ALTER TABLE TMPFaturamento_NotaFiscal_Vencimento ADD CONSTRAINT PrimaryKey PRIMARY KEY (NotaFiscal);
GO
ALTER TABLE TMPFaturamento_NotaFiscal_EnderecoEntrega ADD CONSTRAINT PrimaryKey PRIMARY KEY (NFe);
GO
ALTER TABLE TMPFaturamento_NotaFiscal_EnderecoRetirada ADD CONSTRAINT PrimaryKey PRIMARY KEY (NFe)
GO
CREATE INDEX TMPFaturamento_NotaFiscal_movimento_NotaFiscal ON TMPFaturamento_NotaFiscal_movimento (NotaFiscal);