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

/****** Object:  Table [dbo].[EST_PED_ELTR_FORN_FALTAS]    Script Date: 18/11/2014 17:13:45 ******/
SET ANSI_NULLS ON 
SET QUOTED_IDENTIFIER ON  
SET ANSI_PADDING ON 


	CREATE TABLE [dbo].[EST_PED_ELTR_FORN_FALTAS](
		[CD_EMP] [int] NOT NULL CONSTRAINT [DF_EST_PED_ELTR_FORN_FALTAS_CD_EMP]  DEFAULT ((0)),
		[CD_PED_SOL] [int] NOT NULL CONSTRAINT [DF_EST_PED_ELTR_FORN_FALTAS_CD_PED_COL]  DEFAULT ((0)),
		[CD_FORN] [int] NOT NULL CONSTRAINT [DF_EST_PED_ELTR_FORN_FALTAS_CD_FORN]  DEFAULT ((0)),
		[CD_PROD] [int] NOT NULL CONSTRAINT [DF_EST_PED_ELTR_FORN_FALTAS_CD_PROD]  DEFAULT ((0)),
		[CD_MSG_FORN] [varchar](6) NOT NULL,
	 CONSTRAINT [PK_EST_PED_ELTR_FORN_FALTAS] PRIMARY KEY CLUSTERED 
	(	[CD_EMP] ASC,
		[CD_PED_SOL] ASC,
		[CD_FORN] ASC,
		[CD_PROD] 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_PED_ELTR_FORN_FALTAS]  WITH CHECK ADD  CONSTRAINT [FK_EST_PED_ELTR_FORN_FALTAS_EST_PED_ELTR_IT] 
		FOREIGN KEY([CD_EMP], [CD_PED_SOL], [CD_PROD])
	REFERENCES [dbo].[EST_PED_ELTR_IT] ([CD_EMP], [CD_PED_SOL], [CD_PROD])
	 
	ALTER TABLE [dbo].[EST_PED_ELTR_FORN_FALTAS] CHECK CONSTRAINT [FK_EST_PED_ELTR_FORN_FALTAS_EST_PED_ELTR_IT] 
END