IF NOT EXISTS (SELECT * FROM SYS.TABLES WHERE NAME = 'EST_PROD_TBL_DESC_RC_VD_CONV')
Begin
CREATE TABLE [dbo].[EST_PROD_TBL_DESC_RC_VD_CONV](
	[CD_EMP] [int] NOT NULL,
	[CD_TBL_DESC] [int] NOT NULL,
	[CD_CONV] [int] NOT NULL,
	[CD_USU] [int] NOT NULL,
	[DT_CAD] [datetime] NOT NULL,
 CONSTRAINT [PK_EST_PROD_TBL_DESC_RC_VD_CONV] PRIMARY KEY CLUSTERED 
(
	[CD_EMP] ASC,
	[CD_TBL_DESC] ASC,
	[CD_CONV] 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_TBL_DESC_RC_VD_CONV]  WITH CHECK ADD  CONSTRAINT [FK_EST_PROD_TBL_DESC_RC_VD_CONV_EST_PROD_TBL_DESC] FOREIGN KEY([CD_EMP], [CD_TBL_DESC])
REFERENCES [dbo].[EST_PROD_TBL_DESC] ([CD_EMP], [CD_TBL_DESC])

ALTER TABLE [dbo].[EST_PROD_TBL_DESC_RC_VD_CONV] CHECK CONSTRAINT [FK_EST_PROD_TBL_DESC_RC_VD_CONV_EST_PROD_TBL_DESC]

ALTER TABLE [dbo].[EST_PROD_TBL_DESC_RC_VD_CONV]  WITH CHECK ADD  CONSTRAINT [FK_EST_PROD_TBL_DESC_RC_VD_CONV_RC_CLI_CONV] FOREIGN KEY([CD_EMP], [CD_CONV])
REFERENCES [dbo].[RC_CLI_CONV] ([CD_EMP], [CD_CONV])

ALTER TABLE [dbo].[EST_PROD_TBL_DESC_RC_VD_CONV] CHECK CONSTRAINT [FK_EST_PROD_TBL_DESC_RC_VD_CONV_RC_CLI_CONV]
end

