IF  NOT EXISTS (SELECT * FROM sys.objects 
					WHERE object_id = OBJECT_ID(N'[dbo].[EST_ORC_CPL_FALTA]') 
					AND type in (N'U')) 
BEGIN

SET ANSI_NULLS ON 
SET QUOTED_IDENTIFIER ON  
SET ANSI_PADDING ON  

	CREATE TABLE [dbo].[EST_ORC_CPL_FALTA](
		CD_CTR		[int]  IDENTITY (1,1)  ,
		CD_EMP		[int] NOT NULL CONSTRAINT [DF_EST_ORC_CPL_FALTA_CD_EMP]  DEFAULT ((0)),
		CD_FILIAL	[int] NOT NULL CONSTRAINT [DF_EST_ORC_CPL_FALTA_CD_FILIAL]  DEFAULT ((0)),
		CD_PROD		[int] NOT NULL CONSTRAINT [DF_EST_ORC_CPL_FALTA_CD_PROD]  DEFAULT ((0)),
		QTDE		[Money] NOT NULL CONSTRAINT [DF_EST_ORC_CPL_FALTA_QTDE]  DEFAULT ((0)),
		DT_FALTA	DATETIME ,
		CD_VEND		[int] NOT NULL CONSTRAINT [DF_EST_ORC_CPL_FALTA_CD_VEND]  DEFAULT ((0)),
		QTDE_ESTOQUE [Money] NOT NULL CONSTRAINT [DF_EST_ORC_CPL_FALTA_QTDE_ESTOQUE]  DEFAULT ((0)),
	 CONSTRAINT [PK_EST_ORC_CPL_FALTA] PRIMARY KEY CLUSTERED 
		(CD_CTR)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_ORC_CPL_FALTA]  WITH CHECK ADD  CONSTRAINT [FK_EST_ORC_CPL_FALTA_EST_PROD] 
		FOREIGN KEY([CD_EMP], [CD_PROD])
	REFERENCES [dbo].[EST_PROD] ([CD_EMP], [CD_PROD])
	 
	ALTER TABLE [dbo].[EST_ORC_CPL_FALTA] CHECK CONSTRAINT [FK_EST_ORC_CPL_FALTA_EST_PROD] 
END