-- Constrolar os pedidos da API MAIS ENTREGA
-- STATUS =  1 true - 0 false 
IF  NOT EXISTS (SELECT * FROM sys.objects 
					WHERE object_id = OBJECT_ID(N'[dbo].[TELE_ORC_TRANSPORTE_TRANSACAO]') 
					AND type in (N'U')) 
BEGIN
	SET ANSI_NULLS ON
	SET QUOTED_IDENTIFIER ON
	SET ANSI_PADDING ON
	CREATE TABLE [dbo].[TELE_ORC_TRANSPORTE_TRANSACAO](
	    [CD_CTR] 			[int]	NOT NULL IDENTITY(1,1), 
		[CD_ORC] 			[int] 	NOT NULL ,
		[SUCCESS] 			[BIT] 	NOT NULL,
	 	[ERRO] 	  			[TEXT] 	NULL  ,
		[MESSAGE] 			[TEXT] 	NULL,
		[JSON_ENVIADO] 		[TEXT] 	NOT NULL,
		[JSON_RETORNADO] 	[TEXT] 	NULL,
		[DT_CAD] 			[DATETIME] 	NOT NULL DEFAULT (GETDATE())
	 CONSTRAINT [PK__TELE_ORC_TRANSPORTE_TRANSACAO] PRIMARY KEY CLUSTERED (CD_CTR) 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 TELE_ORC_TRANSPORTE_TRANSACAO ADD CONSTRAINT FK_TELE_ORC_TRANSPORTE_TRANSACAO_NR_PEDIDO FOREIGN KEY (CD_ORC) REFERENCES TELE_ORC (CD_ORC)
 
 END;