IF NOT EXISTS(SELECT 1 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME='INTEGRA_ECOMMERCE_REGIAO') 
BEGIN
CREATE TABLE [dbo].[INTEGRA_ECOMMERCE_PEDIDO](
	[ID] [int] IDENTITY(1,1) NOT NULL,
	[ECOMMERCE] [varchar](20) NOT NULL,
	[CODIGO_PEDIDO] [varchar](20) NOT NULL,
	[VALOR_PEDIDO] [money] NOT NULL,
	[NOME_CLIENTE] [varchar](255) NULL,
	[DATA_PEDIDO] [datetime] NOT NULL,
	[CODIGO_STATUS] [varchar](20) NULL,
	[FALHOU] [bit] NULL,
	[MENSAGEM_ERRO] [varchar](1000) NULL,
	[CD_ORC] [int] NULL,
	[DT_ORC] [datetime] NULL,
	[CD_ETAPA] [int] NULL,
	[TIPO_ETAPA] [int] NULL,
	[DTHR_ETAPA] [datetime] NULL,
	[OBS_ETAPA] [varchar](255) NULL,
	[DT_ULT_ALT] [datetime] NULL,
	[FINALIZADO] [bit] NULL,
	[JSON_PEDIDO] [text] NULL,
	[IS_MARKET_PLACE] [tinyint] NULL,
	[MARKET_PLACE_ORDER_ID] [varchar](200) NULL,
	[PEND_ATUALIZACAO] [tinyint] NULL,
	[NOME_MARKET_PLACE] [varchar](200) NULL,
 CONSTRAINT [PK_INTEGRA_ECOMMERCE_PEDIDO] PRIMARY KEY CLUSTERED 
(
	[ECOMMERCE] ASC,
	[CODIGO_PEDIDO] ASC
)WITH (PAD_INDEX = OFF) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
END


