IF NOT EXISTS(SELECT 1 FROM [dbo].[controledbad])
BEGIN
	DECLARE @banco VARCHAR(255) = (SELECT DB_NAME());
	INSERT INTO [dbo].[controledbad] (bdname, tabela) VALUES (@banco, N'Arquivos');
	
	CREATE TABLE [dbo].[Arquivos](
	[IDARQUIVODIGITAL] [bigint] IDENTITY(1,1) NOT NULL PRIMARY KEY,
	[IDCLIENTE] [bigint] NULL,
	[IDDOCUMENTO] [bigint] NULL,
	[IDATENDIMENTO] [bigint] NULL,
	[IDITEM] [bigint] NULL,
	[IDPARCELA] [bigint] NULL,
	[IDSINISTRO] [bigint] NULL,
	[IDVENCTOALEATORIO] [bigint] NULL,
	[IDMALADIRETA] [bigint] NULL,
	[IDFORNECEDOR] [bigint] NULL,
	[IDCIASEG] [bigint] NULL,
	[IDORCCLI] [bigint] NULL,
	[IDORCAMEN] [bigint] NULL,
	[IDORCITEM] [bigint] NULL,
	[IDVENDEDOR] [bigint] NULL,
	[IDEXTRATO] [bigint] NULL,
	[IDLANCAMEN] [bigint] NULL,
	[IDEMPRESA] [bigint] NULL,
	[IDSOCIO] [bigint] NULL,
	[DESCRICAO] [varchar](300) NULL,
	[IMGBLOB] [varbinary](max) NULL,
	[EXTENSION] [varchar](5) NULL,
	[USUARIOCRIACAO] [bigint] NULL,
	[USUARIOALTERACAO] [bigint] NULL,
	[DATACRIACAO] [datetime] NULL,
	[DATAALTERACAO] [datetime] NULL,
	[idrecibofiscal] [bigint] NULL,
	[idprojeto] [bigint] NULL,
	[idagsproduto] [bigint] NULL,
	[excluido] [varchar](1) NULL,
	[idnota] [bigint] NULL,
	[idguiaremessa] [bigint] NULL);
END