/****** Object:  Table [dbo].[EST_PROD_TRANSF_ERROS_VALIDACAO]    Script Date: 02/03/2014 12:08:07 ******/
IF  NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[EST_PROD_TRANSF_ERROS_VALIDACAO]') AND type in (N'U'))
begin
	CREATE TABLE [dbo].[EST_PROD_TRANSF_ERROS_VALIDACAO](
		[CD_CTR_ERROS] [int] IDENTITY(1,1) NOT NULL,
		[CD_EMP] [int] NOT NULL,
		[CD_FILIAL] [int] NOT NULL,
		[CD_CTR] [int] NOT NULL,
		[DT_CAD] [datetime] NOT NULL,
		[ERROS_VALIDACAO] [xml] NOT NULL,
		[STS_ERRO] [int] NULL,
		[CD_USU] [int] NOT NULL,
		[DT_CAD_CORRECAO] [datetime] NULL,
		[VERSAO_APLIC] [varchar](150) NOT NULL,
	 CONSTRAINT [PK_EST_PROD_TRANSF_ERROS_VALIDACAO] PRIMARY KEY CLUSTERED 
	(
		[CD_CTR_ERROS] 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_PROD_TRANSF_ERROS_VALIDACAO]  WITH CHECK ADD  CONSTRAINT [FK_EST_PROD_TRANSF_ERROS_VALIDACAO_EST_PROD_TRANSF] FOREIGN KEY([CD_EMP], [CD_FILIAL], [CD_CTR])
	REFERENCES [dbo].[EST_PROD_TRANSF] ([CD_EMP], [CD_FILIAL], [CD_CTR])

	ALTER TABLE [dbo].[EST_PROD_TRANSF_ERROS_VALIDACAO] CHECK CONSTRAINT [FK_EST_PROD_TRANSF_ERROS_VALIDACAO_EST_PROD_TRANSF]

	ALTER TABLE [dbo].[EST_PROD_TRANSF_ERROS_VALIDACAO] ADD  CONSTRAINT [DF_EST_PROD_TRANSF_ERROS_VALIDACAO_CD_EMP]  DEFAULT ((0)) FOR [CD_EMP]

	ALTER TABLE [dbo].[EST_PROD_TRANSF_ERROS_VALIDACAO] ADD  CONSTRAINT [DF_EST_PROD_TRANSF_ERROS_VALIDACAO_CD_FILIAL]  DEFAULT ((0)) FOR [CD_FILIAL]

	ALTER TABLE [dbo].[EST_PROD_TRANSF_ERROS_VALIDACAO] ADD  CONSTRAINT [DF_EST_PROD_TRANSF_ERROS_VALIDACAO_CD_CTR]  DEFAULT ((0)) FOR [CD_CTR]

	ALTER TABLE [dbo].[EST_PROD_TRANSF_ERROS_VALIDACAO] ADD  CONSTRAINT [DF_EST_PROD_TRANSF_ERROS_VALIDACAO_DT_CAD]  DEFAULT (getdate()) FOR [DT_CAD]

	ALTER TABLE [dbo].[EST_PROD_TRANSF_ERROS_VALIDACAO] ADD  CONSTRAINT [DF_EST_PROD_TRANSF_ERROS_VALIDACAO_STS_ERRO]  DEFAULT ((0)) FOR [STS_ERRO]

	ALTER TABLE [dbo].[EST_PROD_TRANSF_ERROS_VALIDACAO] ADD  CONSTRAINT [DF_EST_PROD_TRANSF_ERROS_VALIDACAO_CD_USU]  DEFAULT ((0)) FOR [CD_USU]

	ALTER TABLE [dbo].[EST_PROD_TRANSF_ERROS_VALIDACAO] ADD  CONSTRAINT [DF_EST_PROD_TRANSF_ERROS_VALIDACAO_VERSAO_APLIC]  DEFAULT ('') FOR [VERSAO_APLIC]
end