IF  NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[EST_NF_ENT_DANFE_PROVISORIO_EST_NF_ENT_CONFIRMACAO_OPERACAO_PENDENTE]') AND type in (N'U'))
begin
	SET ANSI_NULLS ON
	SET QUOTED_IDENTIFIER ON
	CREATE TABLE [dbo].[EST_NF_ENT_DANFE_PROVISORIO_EST_NF_ENT_CONFIRMACAO_OPERACAO_PENDENTE](
		[CD_EMP] [int] NOT NULL CONSTRAINT [DF_EST_NF_ENT_DANFE_PROVISORIO_EST_NF_ENT_CONFIRMACAO_OPERACAO_PENDENTE_CD_EMP]  DEFAULT ((0)),
		[CD_FILIAL] [int] NOT NULL CONSTRAINT [DF_EST_NF_ENT_DANFE_PROVISORIO_EST_NF_ENT_CONFIRMACAO_OPERACAO_PENDENTE_CD_FILIAL]  DEFAULT ((0)),
		[CD_NF] [int] NOT NULL CONSTRAINT [DF_EST_NF_ENT_DANFE_PROVISORIO_EST_NF_ENT_CONFIRMACAO_OPERACAO_PENDENTE_CD_NF]  DEFAULT ((0)),
		[CD_CTR] [int] NOT NULL CONSTRAINT [DF_EST_NF_ENT_DANFE_PROVISORIO_EST_NF_ENT_CONFIRMACAO_OPERACAO_PENDENTE_CD_CTR]  DEFAULT ((0)),
		[DT_CAD] [datetime] NOT NULL CONSTRAINT [DF_EST_NF_ENT_DANFE_PROVISORIO_EST_NF_ENT_CONFIRMACAO_OPERACAO_PENDENTE_DT_CAD]  DEFAULT (getdate()),
	 CONSTRAINT [PK_EST_NF_ENT_DANFE_PROVISORIO_EST_NF_ENT_CONFIRMACAO_OPERACAO_PENDENTE] PRIMARY KEY CLUSTERED 
	(
		[CD_EMP] ASC,
		[CD_FILIAL] ASC,
		[CD_NF] ASC,
		[CD_CTR] 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].[EST_NF_ENT_DANFE_PROVISORIO_EST_NF_ENT_CONFIRMACAO_OPERACAO_PENDENTE]  WITH CHECK ADD  CONSTRAINT [FK_EST_NF_ENT_DANFE_PROVISORIO_EST_NF_ENT_CONFIRMACAO_OPERACAO_PENDENTE_EST_NF_ENT_DANFE_PROVISORIO_EST_NF_ENT] FOREIGN KEY([CD_EMP], [CD_FILIAL], [CD_NF], [CD_CTR])
	REFERENCES [dbo].[EST_NF_ENT_DANFE_PROVISORIO_EST_NF_ENT] ([CD_EMP], [CD_FILIAL], [CD_NF], [CD_CTR])
	ALTER TABLE [dbo].[EST_NF_ENT_DANFE_PROVISORIO_EST_NF_ENT_CONFIRMACAO_OPERACAO_PENDENTE] CHECK CONSTRAINT [FK_EST_NF_ENT_DANFE_PROVISORIO_EST_NF_ENT_CONFIRMACAO_OPERACAO_PENDENTE_EST_NF_ENT_DANFE_PROVISORIO_EST_NF_ENT]
end
