IF  NOT EXISTS (SELECT * FROM sys.objects 
					WHERE object_id = OBJECT_ID(N'[dbo].[EST_TOP_SHOW_PRC_FILIAL]') 
					AND type in (N'U')) 
BEGIN
	/****** Object:  Table [dbo].[EST_TOP_SHOW_PRC_FILIAL]    Script Date: 19/12/2015 16:23:42 ******/
	SET ANSI_NULLS ON
	SET QUOTED_IDENTIFIER ON

	CREATE TABLE [dbo].[EST_TOP_SHOW_PRC_FILIAL](
		[CD_EMP] [int] NOT NULL,
		[CD_TOP_SHOW] [int] NOT NULL,
		[CD_FILIAL] [int] NOT NULL,
	 CONSTRAINT [PK_EST_TOP_SHOW_PRC_FILIAL] PRIMARY KEY CLUSTERED 
	(
		[CD_TOP_SHOW] ASC,
		[CD_FILIAL] ASC,
		[CD_EMP] 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_TOP_SHOW_PRC_FILIAL]  WITH CHECK 
		ADD  CONSTRAINT [FK_EST_TOP_SHOW_PRC_FILIAL_EST_TOP_SHOW_CD_TOP_SHOW] FOREIGN KEY([CD_TOP_SHOW],[CD_EMP])
	REFERENCES [dbo].[EST_TOP_SHOW] ([CD_TOP_SHOW],[CD_EMP])
	ON UPDATE CASCADE
	ON DELETE CASCADE

	ALTER TABLE [dbo].[EST_TOP_SHOW_PRC_FILIAL] CHECK CONSTRAINT [FK_EST_TOP_SHOW_PRC_FILIAL_EST_TOP_SHOW_CD_TOP_SHOW]

	ALTER TABLE [dbo].[EST_TOP_SHOW_PRC_FILIAL]  WITH CHECK ADD  CONSTRAINT [FK_EST_TOP_SHOW_PRC_FILIAL_PRC_FILIAL] FOREIGN KEY([CD_EMP], [CD_FILIAL])
	REFERENCES [dbo].[PRC_FILIAL] ([CD_EMP], [CD_FILIAL])
	ON UPDATE CASCADE
	ALTER TABLE [dbo].[EST_TOP_SHOW_PRC_FILIAL] CHECK CONSTRAINT [FK_EST_TOP_SHOW_PRC_FILIAL_PRC_FILIAL]
END
