IF OBJECT_ID('EST_PED_CP_PARAM_PG_FORN_INTEGRACAO') IS NULL
	BEGIN 
		CREATE TABLE [dbo].[EST_PED_CP_PARAM_PG_FORN_INTEGRACAO](
			[CD_EMP] [int] NOT NULL,
			[CD_PED_CP_PARAM] [int] NOT NULL,
			[CD_ORD_CP_PARAM] [int] NOT NULL,
			[CD_FORN] [int] NOT NULL,
			[CD_INT] [int] NOT NULL,
			[CONDICAO] [varchar](50) NULL,
			[CD_USU] [int] NOT NULL,
			[DT_CAD] [datetime] NOT NULL,
			[DT_ULT_ALT] [datetime] NULL,
		 CONSTRAINT [PK_EST_PED_CP_PARAM_PG_FORN_INTEGRACAO] PRIMARY KEY CLUSTERED 
		(
			[CD_EMP] ASC,
			[CD_PED_CP_PARAM] ASC,
			[CD_ORD_CP_PARAM] 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]

		

		SET ANSI_PADDING OFF
		

		ALTER TABLE [dbo].[EST_PED_CP_PARAM_PG_FORN_INTEGRACAO]  WITH CHECK ADD  CONSTRAINT [FK_EST_PED_CP_PARAM_PG_FORN_INTEGRACAO_EST_PED_CP_PARAM] FOREIGN KEY([CD_EMP], [CD_PED_CP_PARAM])
		REFERENCES [dbo].[EST_PED_CP_PARAM] ([CD_EMP], [CD_PED_CP_PARAM])
		ON UPDATE CASCADE
		ON DELETE CASCADE
		

		ALTER TABLE [dbo].[EST_PED_CP_PARAM_PG_FORN_INTEGRACAO] CHECK CONSTRAINT [FK_EST_PED_CP_PARAM_PG_FORN_INTEGRACAO_EST_PED_CP_PARAM]
		

		ALTER TABLE [dbo].[EST_PED_CP_PARAM_PG_FORN_INTEGRACAO]  WITH CHECK ADD  CONSTRAINT [FK_EST_PED_CP_PARAM_PG_FORN_INTEGRACAO_GLB_USU] FOREIGN KEY([CD_USU])
		REFERENCES [dbo].[GLB_USU] ([CD_USU])
		

		ALTER TABLE [dbo].[EST_PED_CP_PARAM_PG_FORN_INTEGRACAO] CHECK CONSTRAINT [FK_EST_PED_CP_PARAM_PG_FORN_INTEGRACAO_GLB_USU]
		

		ALTER TABLE [dbo].[EST_PED_CP_PARAM_PG_FORN_INTEGRACAO]  WITH CHECK ADD  CONSTRAINT [FK_EST_PED_CP_PARAM_PG_FORN_INTEGRACAO_PG_FORN_INTEGRACAO] FOREIGN KEY([CD_EMP], [CD_FORN], [CD_INT])
		REFERENCES [dbo].[PG_FORN_INTEGRACAO] ([CD_EMP], [CD_FORN], [CD_INT])
		ON UPDATE CASCADE
		ON DELETE CASCADE
		

		ALTER TABLE [dbo].[EST_PED_CP_PARAM_PG_FORN_INTEGRACAO] CHECK CONSTRAINT [FK_EST_PED_CP_PARAM_PG_FORN_INTEGRACAO_PG_FORN_INTEGRACAO]
		

		ALTER TABLE [dbo].[EST_PED_CP_PARAM_PG_FORN_INTEGRACAO]  WITH CHECK ADD  CONSTRAINT [FK_EST_PED_CP_PARAM_PG_FORN_INTEGRACAO_PRC_EMP] FOREIGN KEY([CD_EMP])
		REFERENCES [dbo].[PRC_EMP] ([CD_EMP])
		

		ALTER TABLE [dbo].[EST_PED_CP_PARAM_PG_FORN_INTEGRACAO] CHECK CONSTRAINT [FK_EST_PED_CP_PARAM_PG_FORN_INTEGRACAO_PRC_EMP]
		

	END