IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[EST_PED_CP_PED_CP_FORN_VINCULADO]')) 
	BEGIN 
		RETURN;
	END
ELSE
BEGIN
	/****** Object:  Table [dbo].[EST_PED_CP_PED_CP_FORN_VINCULADO]    Script Date: 07/06/2014 10:40:53 ******/
	SET ANSI_NULLS ON
	SET QUOTED_IDENTIFIER ON

	CREATE TABLE [dbo].[EST_PED_CP_PED_CP_FORN_VINCULADO](
		[CD_EMP] [int] NOT NULL,
		[CD_FILIAL] [int] NOT NULL,
		[CD_PED] [int] NOT NULL,
		[CD_PED_VINC] [int] NOT NULL,
		[CD_USU] [int] NOT NULL,
		[DT_CAD] [datetime] NULL,
	 CONSTRAINT [PK_EST_PED_CP_PED_CP_FORN_VINCULADO] PRIMARY KEY CLUSTERED 
	(
		[CD_EMP] ASC,
		[CD_FILIAL] ASC,
		[CD_PED] ASC,
		[CD_PED_VINC] 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_CP_PED_CP_FORN_VINCULADO] ADD  CONSTRAINT [DF_EST_PED_CP_PED_CP_FORN_VINCULADO_CD_EMP]  DEFAULT ((0)) FOR [CD_EMP]
	ALTER TABLE [dbo].[EST_PED_CP_PED_CP_FORN_VINCULADO] ADD  CONSTRAINT [DF_EST_PED_CP_PED_CP_FORN_VINCULADO_CD_FILIAL]  DEFAULT ((0)) FOR [CD_FILIAL]
	ALTER TABLE [dbo].[EST_PED_CP_PED_CP_FORN_VINCULADO] ADD  CONSTRAINT [DF_EST_PED_CP_PED_CP_FORN_VINCULADO_CD_PED]  DEFAULT ((0)) FOR [CD_PED]
	ALTER TABLE [dbo].[EST_PED_CP_PED_CP_FORN_VINCULADO] ADD  CONSTRAINT [DF_EST_PED_CP_PED_CP_FORN_VINCULADO_CD_PED_VINC]  DEFAULT ((0)) FOR [CD_PED_VINC]
	ALTER TABLE [dbo].[EST_PED_CP_PED_CP_FORN_VINCULADO]  WITH CHECK ADD  
		CONSTRAINT [FK_EST_PED_CP_PED_CP_FORN_VINCULADO_EST_PED_CP] FOREIGN KEY([CD_EMP], [CD_FILIAL], [CD_PED])
	REFERENCES [dbo].[EST_PED_CP] ([CD_EMP], [CD_FILIAL], [CD_PED])
	ON UPDATE CASCADE
	ALTER TABLE [dbo].[EST_PED_CP_PED_CP_FORN_VINCULADO] CHECK CONSTRAINT [FK_EST_PED_CP_PED_CP_FORN_VINCULADO_EST_PED_CP]
END