IF OBJECT_ID('PG_FORN_INTEGRACAO') IS NULL
	BEGIN 
		CREATE TABLE [dbo].[PG_FORN_INTEGRACAO](
			[CD_EMP] [int] NOT NULL,
			[CD_FORN] [int] NOT NULL,
			[CD_INT] [int] NOT NULL,
			[TP_INT] [int] NULL,
			[DS_INT] [varchar](100) NULL,
			[END_INT] [varchar](150) NULL,
			[USU_INT] [varchar](100) NULL,
			[SENHA_INT] [varchar](50) NULL,
			[DIR_ENVIO] [varchar](150) NULL,
			[DIR_RETORNO] [varchar](150) NULL,
			[NM_ARQ_ENVIO] [varchar](100) NULL,
			[NM_ARQ_RETORNO] [varchar](100) NULL,
			[ENVIA_EMAIL] [varchar](500) NULL,
			[ASSUNTO_EMAIL] [varchar](100) NULL,
			[FLAG_INT_PAD] [int] NULL,
			[DIR_PROCESSADO] [varchar](150) NULL,
			[NM_ARQ_PROCESSADO] [varchar](100) NULL,
			[TP_LAYOUT] [int] NULL,
		 CONSTRAINT [PK_PG_FORN_INTEGRACAO] PRIMARY KEY CLUSTERED 
		(
			[CD_EMP] ASC,
			[CD_FORN] ASC,
			[CD_INT] 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].[PG_FORN_INTEGRACAO]  WITH CHECK ADD  CONSTRAINT [FK_PG_FORN_INTEGRACAO_PG_FORN] FOREIGN KEY([CD_EMP], [CD_FORN])
		REFERENCES [dbo].[PG_FORN] ([CD_EMP], [CD_FORN])
		ON UPDATE CASCADE
		ON DELETE CASCADE
		

		ALTER TABLE [dbo].[PG_FORN_INTEGRACAO] CHECK CONSTRAINT [FK_PG_FORN_INTEGRACAO_PG_FORN]
		

		ALTER TABLE [dbo].[PG_FORN_INTEGRACAO] ADD  CONSTRAINT [DF_PG_FORN_INTEGRACAO_FLAG_INT_PAD]  DEFAULT ((0)) FOR [FLAG_INT_PAD]
		

		ALTER TABLE [dbo].[PG_FORN_INTEGRACAO] ADD  CONSTRAINT [DF_PG_FORN_INTEGRACAO_DIR_PROCESSADO]  DEFAULT ('') FOR [DIR_PROCESSADO]
		

		ALTER TABLE [dbo].[PG_FORN_INTEGRACAO] ADD  CONSTRAINT [DF_PG_FORN_INTEGRACAO_NM_ARQ_PROCESSADO]  DEFAULT ('') FOR [NM_ARQ_PROCESSADO]
		

		ALTER TABLE [dbo].[PG_FORN_INTEGRACAO] ADD  CONSTRAINT [DF_PG_FORN_INTEGRACAO_TP_LAYOUT]  DEFAULT ((0)) FOR [TP_LAYOUT]
		
	END

