IF	OBJECT_ID('EST_PROD_TBL_FIDEL') IS NULL
begin
CREATE TABLE [dbo].[EST_PROD_TBL_FIDEL](
	[CD_EMP] [int] NOT NULL,
	[CD_TBL_FIDEL] [int] NOT NULL,
	[DS_TBL_FIDEL] [varchar](100) NOT NULL,
	[CD_INTEGRADORA] [int] NOT NULL,
	[CD_PROMOCAO_INT] [varchar](100) NOT NULL,
	[DT_INI] [datetime] NOT NULL,
	[DT_FIM] [datetime] NOT NULL,
	[CD_USU] [int] NOT NULL,
	[DT_CAD] [datetime] NULL,
	[DT_ULT_ALT] [datetime] NULL,
 CONSTRAINT [PK_EST_PROD_TBL_FIDEL] PRIMARY KEY CLUSTERED 
(
	[CD_EMP] ASC,
	[CD_TBL_FIDEL] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [IX_EST_PROD_TBL_FIDEL] UNIQUE NONCLUSTERED 
(
	[DS_TBL_FIDEL] 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_FIDEL] ADD  CONSTRAINT [DF_EST_PROD_TBL_FIDEL_CD_EMP]  DEFAULT ((0)) FOR [CD_EMP]

ALTER TABLE [dbo].[EST_PROD_TBL_FIDEL] ADD  CONSTRAINT [DF_EST_PROD_TBL_FIDEL_CD_TBL_FIDEL]  DEFAULT ((0)) FOR [CD_TBL_FIDEL]

ALTER TABLE [dbo].[EST_PROD_TBL_FIDEL] ADD  CONSTRAINT [DF_EST_PROD_TBL_FIDEL_DS_TBL_FIDEL]  DEFAULT ('') FOR [DS_TBL_FIDEL]

ALTER TABLE [dbo].[EST_PROD_TBL_FIDEL] ADD  CONSTRAINT [DF_EST_PROD_TBL_FIDEL_CD_INTEGRADORA]  DEFAULT ((0)) FOR [CD_INTEGRADORA]

ALTER TABLE [dbo].[EST_PROD_TBL_FIDEL] ADD  CONSTRAINT [DF_EST_PROD_TBL_FIDEL_CD_USU]  DEFAULT ((0)) FOR [CD_USU]

ALTER TABLE [dbo].[EST_PROD_TBL_FIDEL] ADD  CONSTRAINT [DF_EST_PROD_TBL_FIDEL_DT_CAD]  DEFAULT (getdate()) FOR [DT_CAD]

ALTER TABLE [dbo].[EST_PROD_TBL_FIDEL] ADD  CONSTRAINT [DF_EST_PROD_TBL_FIDEL_CD_PROMOCAO_INT]  DEFAULT ('') FOR [CD_PROMOCAO_INT]

ALTER TABLE [dbo].[EST_PROD_TBL_FIDEL]  WITH CHECK ADD  CONSTRAINT [FK_EST_PROD_TBL_FIDEL_EST_PROD_TBL_FIDEL_INTEGRADORA] FOREIGN KEY([CD_INTEGRADORA])
REFERENCES [dbo].[EST_PROD_TBL_FIDEL_INTEGRADORA] ([CD_INTEGRADORA])

ALTER TABLE [dbo].[EST_PROD_TBL_FIDEL] CHECK CONSTRAINT [FK_EST_PROD_TBL_FIDEL_EST_PROD_TBL_FIDEL_INTEGRADORA]
end

