IF  NOT EXISTS (SELECT * FROM sys.objects 
					WHERE object_id = OBJECT_ID(N'[dbo].[RC_CLI_CONV_PBM_EST_PROD_TBL_DESC_QTDE]') 
					AND type in (N'U')) 
begin
CREATE TABLE [dbo].[RC_CLI_CONV_PBM_EST_PROD_TBL_DESC_QTDE](
	[CD_EMP] [int] NOT NULL,
	[CD_CONV] [int] NOT NULL,
	[CD_TBL_DESC_QTDE] [int] NOT NULL,
	[CD_USU] [int] NOT NULL,
	[DT_CAD] [datetime] NULL,
 CONSTRAINT [PK_RC_CLI_CONV_PBM_EST_PROD_TBL_DESC_QTDE] PRIMARY KEY CLUSTERED 
(
	[CD_EMP] ASC,
	[CD_CONV] ASC,
	[CD_TBL_DESC_QTDE] 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].[RC_CLI_CONV_PBM_EST_PROD_TBL_DESC_QTDE] ADD  CONSTRAINT [DF_RC_CLI_CONV_PBM_EST_PROD_TBL_DESC_QTDE_CD_EMP]  DEFAULT ((0)) FOR [CD_EMP]

ALTER TABLE [dbo].[RC_CLI_CONV_PBM_EST_PROD_TBL_DESC_QTDE] ADD  CONSTRAINT [DF_RC_CLI_CONV_PBM_EST_PROD_TBL_DESC_QTDE_CD_CONV]  DEFAULT ((0)) FOR [CD_CONV]

ALTER TABLE [dbo].[RC_CLI_CONV_PBM_EST_PROD_TBL_DESC_QTDE] ADD  CONSTRAINT [DF_RC_CLI_CONV_PBM_EST_PROD_TBL_DESC_QTDE_CD_TBL_DESC_QTDE]  DEFAULT ((0)) FOR [CD_TBL_DESC_QTDE]

ALTER TABLE [dbo].[RC_CLI_CONV_PBM_EST_PROD_TBL_DESC_QTDE] ADD  CONSTRAINT [DF_RC_CLI_CONV_PBM_EST_PROD_TBL_DESC_QTDE_CD_USU]  DEFAULT ((0)) FOR [CD_USU]

ALTER TABLE [dbo].[RC_CLI_CONV_PBM_EST_PROD_TBL_DESC_QTDE]  WITH CHECK ADD  CONSTRAINT [FK_RC_CLI_CONV_PBM_EST_PROD_TBL_DESC_QTDE_EST_PROD_TBL_DESC_QTDE] FOREIGN KEY([CD_EMP], [CD_TBL_DESC_QTDE])
REFERENCES [dbo].[EST_PROD_TBL_DESC_QTDE] ([CD_EMP], [CD_TBL_DESC_QTDE])

ALTER TABLE [dbo].[RC_CLI_CONV_PBM_EST_PROD_TBL_DESC_QTDE] CHECK CONSTRAINT [FK_RC_CLI_CONV_PBM_EST_PROD_TBL_DESC_QTDE_EST_PROD_TBL_DESC_QTDE]

ALTER TABLE [dbo].[RC_CLI_CONV_PBM_EST_PROD_TBL_DESC_QTDE]  WITH CHECK ADD  CONSTRAINT [FK_RC_CLI_CONV_PBM_EST_PROD_TBL_DESC_QTDE_RC_CLI_CONV_PBM] FOREIGN KEY([CD_EMP], [CD_CONV])
REFERENCES [dbo].[RC_CLI_CONV_PBM] ([CD_EMP], [CD_CONV])

ALTER TABLE [dbo].[RC_CLI_CONV_PBM_EST_PROD_TBL_DESC_QTDE] CHECK CONSTRAINT [FK_RC_CLI_CONV_PBM_EST_PROD_TBL_DESC_QTDE_RC_CLI_CONV_PBM]
end