IF OBJECT_ID('PDV_VD_DEV_EST_PROD_IMP_EST_NF_ENT_DENEGADA') IS NULL 
	BEGIN 
		 
		CREATE TABLE [dbo].[PDV_VD_DEV_EST_PROD_IMP_EST_NF_ENT_DENEGADA](
			[CD_EMP] [int] NOT NULL,
			[CD_FILIAL] [int] NOT NULL,
			[CD_VD] [int] NOT NULL,
			[CD_IMP] [int] NOT NULL,
			[CD_PROD] [int] NOT NULL,
			[CD_NF] [int] NOT NULL,
			[CD_IT] [int] NOT NULL,
		 CONSTRAINT [PK_PDV_VD_DEV_EST_PROD_IMP_EST_NF_ENT_DENEGADA] PRIMARY KEY CLUSTERED 
		(
			[CD_EMP] ASC,
			[CD_FILIAL] ASC,
			[CD_VD] ASC,
			[CD_IMP] ASC,
			[CD_PROD] ASC,
			[CD_NF] ASC,
			[CD_IT] ASC
		)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
		) ON [PRIMARY]

		

		ALTER TABLE [dbo].[PDV_VD_DEV_EST_PROD_IMP_EST_NF_ENT_DENEGADA]  WITH CHECK ADD  CONSTRAINT [FK_PDV_VD_DEV_EST_PROD_IMP_EST_NF_ENT_DENEGADA_EST_NF_ENT_DENEGADA] FOREIGN KEY([CD_EMP], [CD_FILIAL], [CD_NF])
		REFERENCES [dbo].[EST_NF_ENT_DENEGADA] ([CD_EMP], [CD_FILIAL], [CD_NF])
		

		ALTER TABLE [dbo].[PDV_VD_DEV_EST_PROD_IMP_EST_NF_ENT_DENEGADA] CHECK CONSTRAINT [FK_PDV_VD_DEV_EST_PROD_IMP_EST_NF_ENT_DENEGADA_EST_NF_ENT_DENEGADA]
		

		ALTER TABLE [dbo].[PDV_VD_DEV_EST_PROD_IMP_EST_NF_ENT_DENEGADA]  WITH CHECK ADD  CONSTRAINT [FK_PDV_VD_DEV_EST_PROD_IMP_EST_NF_ENT_DENEGADA_PDV_VD_DEV_EST_PROD_IMP] FOREIGN KEY([CD_EMP], [CD_FILIAL], [CD_VD], [CD_IMP], [CD_PROD], [CD_IT])
		REFERENCES [dbo].[PDV_VD_DEV_EST_PROD_IMP] ([CD_EMP], [CD_FILIAL], [CD_VD], [CD_IMP], [CD_PROD], [CD_IT])
		ON UPDATE CASCADE
		ON DELETE CASCADE
		

		ALTER TABLE [dbo].[PDV_VD_DEV_EST_PROD_IMP_EST_NF_ENT_DENEGADA] CHECK CONSTRAINT [FK_PDV_VD_DEV_EST_PROD_IMP_EST_NF_ENT_DENEGADA_PDV_VD_DEV_EST_PROD_IMP]
		

		ALTER TABLE [dbo].[PDV_VD_DEV_EST_PROD_IMP_EST_NF_ENT_DENEGADA] ADD  CONSTRAINT [DF_PDV_VD_DEV_EST_PROD_IMP_EST_NF_ENT_DENEGADA_CD_IT]  DEFAULT ((0)) FOR [CD_IT]
		
		 
	END
