IF OBJECT_ID('EST_PED_ELTR_ATIVA_CP_HIST_ORD_DEFAULT') IS NULL
	BEGIN

		CREATE TABLE [dbo].[EST_PED_ELTR_ATIVA_CP_HIST_ORD_DEFAULT](
			[CD_EMP] [int] NOT NULL,
			[CD_CTR] [int] NOT NULL,
			[CD_CTR_HIST] [int] NOT NULL,
			[CD_IT_HIST] [int] NOT NULL,
			[CD_ROTEIRO] [int] NOT NULL,
			[CD_ORD_DEFAULT] [int] NOT NULL,
			[CD_PED_SOL] [int] NOT NULL,
			[CD_FORN] [int] NOT NULL,
			[CD_INT] [int] NOT NULL,
			[CD_CTR_ENV] [int] NOT NULL,
			[ST_ENV] [int] NOT NULL,
			[DT_HR_ENV] [datetime] NULL,
			[ST_RET] [int] NOT NULL,
			[DT_HR_RET] [datetime] NULL,
			[ST_PED_VAZIO] [int] NOT NULL,
		 CONSTRAINT [PK_EST_PED_ELTR_ATIVA_CP_HIST_ORD_DEFAULT] PRIMARY KEY CLUSTERED 
		(
			[CD_EMP] ASC,
			[CD_CTR] ASC,
			[CD_CTR_HIST] ASC,
			[CD_IT_HIST] ASC
		)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON, FILLFACTOR = 90) ON [PRIMARY]
		) ON [PRIMARY]

		

		ALTER TABLE [dbo].[EST_PED_ELTR_ATIVA_CP_HIST_ORD_DEFAULT]  WITH CHECK ADD  CONSTRAINT [FK_EST_PED_ELTR_ATIVA_CP_HIST_ORD_DEFAULT_EST_PED_CP_ROTEIRO_CP] FOREIGN KEY([CD_ROTEIRO])
		REFERENCES [dbo].[EST_PED_CP_ROTEIRO_CP] ([CD_ROTEIRO])
		

		ALTER TABLE [dbo].[EST_PED_ELTR_ATIVA_CP_HIST_ORD_DEFAULT] CHECK CONSTRAINT [FK_EST_PED_ELTR_ATIVA_CP_HIST_ORD_DEFAULT_EST_PED_CP_ROTEIRO_CP]
		

		ALTER TABLE [dbo].[EST_PED_ELTR_ATIVA_CP_HIST_ORD_DEFAULT]  WITH CHECK ADD  CONSTRAINT [FK_EST_PED_ELTR_ATIVA_CP_HIST_ORD_DEFAULT_EST_PED_ELTR_ATIVA_CP_HIST] FOREIGN KEY([CD_EMP], [CD_CTR], [CD_CTR_HIST])
		REFERENCES [dbo].[EST_PED_ELTR_ATIVA_CP_HIST] ([CD_EMP], [CD_CTR], [CD_CTR_HIST])
		ON UPDATE CASCADE
		ON DELETE CASCADE
		

		ALTER TABLE [dbo].[EST_PED_ELTR_ATIVA_CP_HIST_ORD_DEFAULT] CHECK CONSTRAINT [FK_EST_PED_ELTR_ATIVA_CP_HIST_ORD_DEFAULT_EST_PED_ELTR_ATIVA_CP_HIST]
		

		ALTER TABLE [dbo].[EST_PED_ELTR_ATIVA_CP_HIST_ORD_DEFAULT] ADD  CONSTRAINT [DF_EST_PED_ELTR_ATIVA_CP_HIST_ORD_DEFAULT_CD_INT]  DEFAULT ((0)) FOR [CD_INT]
		

		ALTER TABLE [dbo].[EST_PED_ELTR_ATIVA_CP_HIST_ORD_DEFAULT] ADD  CONSTRAINT [DF_EST_PED_ELTR_ATIVA_CP_HIST_ORD_DEFAULT_CD_CTR_ENV]  DEFAULT ((0)) FOR [CD_CTR_ENV]
		

		ALTER TABLE [dbo].[EST_PED_ELTR_ATIVA_CP_HIST_ORD_DEFAULT] ADD  CONSTRAINT [DF_EST_PED_ELTR_ATIVA_CP_HIST_ORD_DEFAULT_ST_ENV]  DEFAULT ((0)) FOR [ST_ENV]
		

		ALTER TABLE [dbo].[EST_PED_ELTR_ATIVA_CP_HIST_ORD_DEFAULT] ADD  CONSTRAINT [DF_EST_PED_ELTR_ATIVA_CP_HIST_ORD_DEFAULT_ST_RET]  DEFAULT ((0)) FOR [ST_RET]
		

		ALTER TABLE [dbo].[EST_PED_ELTR_ATIVA_CP_HIST_ORD_DEFAULT] ADD  CONSTRAINT [DF_EST_PED_ELTR_ATIVA_CP_HIST_ORD_DEFAULT_ST_PED_VAZIO]  DEFAULT ((0)) FOR [ST_PED_VAZIO]
		

	END