IF	OBJECT_ID('PDV_CX_EST_NF_SERIE') IS NULL
BEGIN
--DROP TABLE	PDV_CX_EST_NF_SERIE
CREATE TABLE	PDV_CX_EST_NF_SERIE (
	CD_CTR		INT IDENTITY(1,1) PRIMARY KEY,
	CD_EMP		INT NOT NULL,
	CD_FILIAL	INT NOT NULL,
	CD_NF_SERIE	INT NOT NULL,
	NR_INI		INT NOT NULL,
	NR_ULT		INT NOT NULL,
	STS_CTR		INT NOT NULL,
	CD_USU		INT NOT NULL,
	DT_CAD		DATETIME NOT NULL DEFAULT GETDATE(),
	DT_ALT		DATETIME NOT NULL DEFAULT GETDATE()	
)

ALTER	TABLE			PDV_CX_EST_NF_SERIE 
		ADD CONSTRAINT	FK_PDV_CX_EST_NF_SERIE_EST_NF_SERIE 
		FOREIGN KEY		(CD_EMP,CD_NF_SERIE) 
		REFERENCES		EST_NF_SERIE (CD_EMP,CD_NF_SERIE)

END

GO

IF COL_LENGTH('PDV_CX','CD_CTR_SERIE') IS NULL
BEGIN
	ALTER TABLE PDV_CX ADD CD_CTR_SERIE INT FOREIGN KEY REFERENCES PDV_CX_EST_NF_SERIE (CD_CTR)
END