
/*------ ATD 237679 ------*/
IF NOT EXISTS (SELECT 1 FROM SYSOBJECTS WHERE xtype='U' AND name='DESPESAS') 
BEGIN
CREATE TABLE DESPESAS(	
	CODDESPESA	INT IDENTITY NOT NULL,
	DESCRICAO	VARCHAR(50) DEFAULT '',
	TIPO		NUMERIC(2) DEFAULT 0
	
)
ALTER TABLE DBO.DESPESAS ADD CONSTRAINT PK_CodDespesa PRIMARY KEY CLUSTERED (CODDESPESA)
END
GO

IF NOT EXISTS (SELECT 1 FROM SYSOBJECTS WHERE xtype='U' AND name='DESPESAVEICULOS') 
BEGIN
CREATE TABLE dbo.DESPESAVEICULOS(	
	ID				INT IDENTITY NOT NULL,
	FILIAL			CHAR(2) DEFAULT '',
	PLACA			CHAR(7) DEFAULT '',
	CODDESPESA		CHAR(5),
	DATAEMISSAO		DATETIME,
	QUANTIDADE		NUMERIC(15,3) DEFAULT 0,
	VALORUNITARIO	NUMERIC(15,3) DEFAULT 0,
	VALORTOTAL		NUMERIC(15,2) DEFAULT 0,
	KM				NUMERIC(9,0) DEFAULT 0,
	KMLITRO			NUMERIC(15,3) DEFAULT 0,
	NUMNOTA			CHAR(13) DEFAULT '',
	SERIE			CHAR(3) DEFAULT ''
)
ALTER TABLE DESPESAVEICULOS ADD CONSTRAINT PK_DESPESAVEICULOS PRIMARY KEY CLUSTERED (ID)
END
GO