/* USER */ 
IF OBJECT_ID('dbo.user','U') IS NOT NULL DROP TABLE dbo.[user]; /* Attenzione il nome coincide con la sintassi MSSQL! */
CREATE TABLE [dbo].[user](
	[_ID_] [int] IDENTITY(1,1) NOT NULL,
	[USERNAME] [nvarchar](16) NOT NULL,
	[USERDESC] [nvarchar](50) NULL,
	[PASSWORD] [nvarchar](8) NOT NULL,
	[GROUPNAME] [nvarchar](8) NULL,
	[ISGROUP] [bit],
	[AUTSTR] [nvarchar](48) NULL,
	[AUTSTR1] [nvarchar](48) NULL,
	[AUTSTR2] [nvarchar](48) NULL,
	[AUTSTR3] [nvarchar](48) NULL,
	[CONNECTED] [bit],
	[PERMISSION] [nvarchar](max) NULL,
	[DATAPWD] [date] NULL
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY];

/* TABGEN */ 
IF OBJECT_ID('dbo.tabgen','U') IS NOT NULL DROP TABLE dbo.tabgen;
CREATE TABLE [dbo].[tabgen](
	[_ID_] [int] IDENTITY(1,1) NOT NULL,
	[COD] [nvarchar](3) NULL,
	[CODTAB] [nvarchar](25) NULL,
	[S0] [nvarchar](70) NULL,
	[S1] [nvarchar](70) NULL,
	[S2] [nvarchar](70) NULL,
	[S3] [nvarchar](70) NULL,
	[S4] [nvarchar](25) NULL,
	[S5] [nvarchar](25) NULL,
	[S6] [nvarchar](5) NULL,
	[S7] [nvarchar](5) NULL,
	[S8] [nvarchar](5) NULL,
	[S9] [nvarchar](5) NULL,
	[S10] [nvarchar](5) NULL,
	[S11] [nvarchar](5) NULL,
	[I0] [float] NULL,
	[I1] [float] NULL,
	[I2] [float] NULL,
	[I3] [float] NULL,
	[I4] [float] NULL,
	[I5] [float] NULL,
	[I6] [float] NULL,
	[I7] [float] NULL,
	[I8] [float] NULL,
	[I9] [float] NULL,
	[I10] [float] NULL,
	[I11] [float] NULL,
	[I12] [float] NULL,
	[I13] [float] NULL,
	[I14] [float] NULL,
	[R0] [float] NULL,
	[R1] [float] NULL,
	[R2] [float] NULL,
	[R3] [float] NULL,
	[R4] [float] NULL,
	[R5] [float] NULL,
	[R6] [float] NULL,
	[R7] [float] NULL,
	[R8] [float] NULL,
	[R9] [float] NULL,
	[R10] [float] NULL,
	[R11] [float] NULL,
	[R12] [float] NULL,
	[R13] [float] NULL,
	[R14] [float] NULL,
	[R15] [float] NULL,
	[R16] [float] NULL,
	[R17] [float] NULL,
	[R18] [float] NULL,
	[R19] [float] NULL,
	[R20] [float] NULL,
	[R21] [float] NULL,
	[R22] [float] NULL,
	[R23] [float] NULL,
	[R24] [float] NULL,
	[R25] [float] NULL,
	[R26] [float] NULL,
	[R27] [float] NULL,
	[R28] [float] NULL,
	[R29] [float] NULL,
	[R30] [float] NULL,
	[R31] [float] NULL,
	[R32] [float] NULL,
	[R33] [float] NULL,
	[D0] [date] NULL,
	[D1] [date] NULL,
	[D2] [date] NULL,
	[D3] [date] NULL,
	[D4] [date] NULL,
	[B0] [bit],
	[B1] [bit],
	[B2] [bit],
	[B3] [bit],
	[B4] [bit],
	[B5] [bit],
	[B6] [bit],
	[B7] [bit],
	[B8] [bit],
	[B9] [bit],
	[B10] [bit],
	[B11] [bit],
	[B12] [bit],
	[B13] [bit],
	[B14] [bit],
	[B15] [bit],
	[FPC] [bit]
) ON [PRIMARY]

/* TABCOM */ 
IF OBJECT_ID('dbo.tabcom','U') IS NOT NULL DROP TABLE dbo.tabcom;
CREATE TABLE [dbo].[tabcom](
	[_ID_] [int] IDENTITY(1,1) NOT NULL,
	[COD] [nvarchar](3) NULL,
	[CODTAB] [nvarchar](25) NULL,
	[S0] [nvarchar](70) NULL,
	[S1] [nvarchar](70) NULL,
	[S2] [nvarchar](70) NULL,
	[S3] [nvarchar](70) NULL,
	[S4] [nvarchar](25) NULL,
	[S5] [nvarchar](25) NULL,
	[S6] [nvarchar](5) NULL,
	[S7] [nvarchar](5) NULL,
	[S8] [nvarchar](5) NULL,
	[S9] [nvarchar](5) NULL,
	[S10] [nvarchar](5) NULL,
	[S11] [nvarchar](5) NULL,
	[S12] [nvarchar](5) NULL,
	[I0] [float] NULL,
	[I1] [float] NULL,
	[I2] [float] NULL,
	[I3] [float] NULL,
	[I4] [float] NULL,
	[I5] [float] NULL,
	[I6] [float] NULL,
	[I7] [float] NULL,
	[I8] [float] NULL,
	[I9] [float] NULL,
	[I10] [float] NULL,
	[I11] [float] NULL,
	[I12] [float] NULL,
	[I13] [float] NULL,
	[I14] [float] NULL,
	[R0] [float] NULL,
	[R1] [float] NULL,
	[R2] [float] NULL,
	[R3] [float] NULL,
	[R4] [float] NULL,
	[R5] [float] NULL,
	[R6] [float] NULL,
	[R7] [float] NULL,
	[R8] [float] NULL,
	[R9] [float] NULL,
	[R10] [float] NULL,
	[R11] [float] NULL,
	[R12] [float] NULL,
	[R13] [float] NULL,
	[R14] [float] NULL,
	[R15] [float] NULL,
	[R16] [float] NULL,
	[R17] [float] NULL,
	[R18] [float] NULL,
	[R19] [float] NULL,
	[R20] [float] NULL,
	[R21] [float] NULL,
	[R22] [float] NULL,
	[R23] [float] NULL,
	[R24] [float] NULL,
	[R25] [float] NULL,
	[R26] [float] NULL,
	[R27] [float] NULL,
	[R28] [float] NULL,
	[R29] [float] NULL,
	[R30] [float] NULL,
	[R31] [float] NULL,
	[R32] [float] NULL,
	[R33] [float] NULL,
	[R34] [float] NULL,
	[D0] [date] NULL,
	[D1] [date] NULL,
	[D2] [date] NULL,
	[D3] [date] NULL,
	[D4] [date] NULL,
	[B0] [bit],
	[B1] [bit],
	[B2] [bit],
	[B3] [bit],
	[B4] [bit],
	[B5] [bit],
	[B6] [bit],
	[B7] [bit],
	[B8] [bit],
	[B9] [bit],
	[B10] [bit],
	[B11] [bit],
	[B12] [bit],
	[B13] [bit],
	[B14] [bit],
	[B15] [bit],
	[DATAAGG] [date] NULL,
	[UTENTE] [nvarchar](16) NULL,
	[FPC] [bit] NULL
) ON [PRIMARY];

IF OBJECT_ID('dbo.anagr','U') IS NOT NULL DROP TABLE dbo.anagr;
CREATE TABLE [dbo].[anagr](
	[_ID_] [int] IDENTITY(1,1) NOT NULL,
	[TIPOA] [nvarchar](1) NULL,
	[CODANAGR] [float] NULL,
	[COFI] [nvarchar](16) NULL,
	[STATOPAIV] [nvarchar](3) NULL,
	[PAIV] [nvarchar](12) NULL,
	[COFIEST] [nvarchar](20) NULL,
	[DATAAGG] [date] NULL,
	[RAGSOC] [nvarchar](50) NULL,
	[STATORES] [nvarchar](3) NULL,
	[COMRES] [nvarchar](4) NULL,
	[INDRES] [nvarchar](35) NULL,
	[CIVRES] [nvarchar](10) NULL,
	[CAPRES] [nvarchar](5) NULL,
	[COMRF] [nvarchar](4) NULL,
	[INDRF] [nvarchar](35) NULL,
	[CIVRF] [nvarchar](10) NULL,
	[CAPRF] [nvarchar](5) NULL,
	[PTELRF] [nvarchar](10) NULL,
	[TELRF] [nvarchar](30) NULL,
	[PFAXRF] [nvarchar](10) NULL,
	[FAXRF] [nvarchar](30) NULL,
	[PTLEXRF] [nvarchar](10) NULL,
	[TLEXRFX] [nvarchar](30) NULL,
	[MAIL] [nvarchar](50) NULL,
	[STATOCORR] [nvarchar](3) NULL,
	[COMCORR] [nvarchar](4) NULL,
	[INDCORR] [nvarchar](35) NULL,
	[CIVCORR] [nvarchar](10) NULL,
	[LOCCORR] [nvarchar](35) NULL,
	[CAPCORR] [nvarchar](5) NULL,
	[CODSTAT1] [nvarchar](7) NULL,
	[CODSTAT2] [nvarchar](7) NULL,
	[CODSTAT3] [nvarchar](7) NULL,
	[CODCONTR] [nvarchar](15) NULL,
	[EVECC] [float] NULL,
	[SOGGNRES] [bit],
	[RESZTERR] [bit],
	[VARSLORES] [bit],
	[DVARSLORES] [date] NULL,
	[VARDF] [bit],
	[DVARDF] [date] NULL,
	[RFDIVERSA] [bit],
	[UFFIIDD] [float] NULL,
	[UFFIVA] [float] NULL,
	[UFFUUE] [float] NULL,
	[TITCF] [bit],
	[TIPOSTDEL] [float] NULL,
	[CODABI] [float] NULL,
	[CODCAB] [float] NULL,
	[NISCRIIDD] [nvarchar](10) NULL,
	[UFFCONC] [float] NULL,
	[OGGETTI] [nvarchar](max) NULL,
	[CAUSQUA] [nvarchar](2) NULL,
	[CATPAR] [nvarchar](2) NULL,
	[ESCPRECOMP] [float] NULL
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY];

IF OBJECT_ID('dbo.nditte','U') IS NOT NULL DROP TABLE dbo.nditte;
CREATE TABLE [dbo].[nditte](
	[_ID_] [int] IDENTITY(1,1) NOT NULL,
	[CODDITTA] [float] NULL,
	[TIPOA] [nvarchar](1) NULL,
	[CODANAGR] [float] NULL,
	[RAGSOC] [nvarchar](50) NULL,
	[PERRIF] [nvarchar](20) NULL,
	[PTEL] [nvarchar](10) NULL,
	[TEL] [nvarchar](30) NULL,
	[PFAX] [nvarchar](10) NULL,
	[FAX] [nvarchar](30) NULL,
	[MAIL] [nvarchar](50) NULL,
	[NULC] [float] NULL,
	[ARTIG] [bit],
	[NISCRAA] [nvarchar](10) NULL,
	[DATAISCRAA] [date] NULL,
	[COMAA] [nvarchar](4) NULL,
	[CAPAA] [nvarchar](5) NULL,
	[FLIVA11Q] [bit],
	[CODATTPREV] [nvarchar](5) NULL,
	[FREQVIVA] [nvarchar](1) NULL,
	[DATLAV] [float] NULL,
	[ABIBAN] [float] NULL,
	[CABBAN] [float] NULL,
	[CONTORD] [bit],
	[DINIZIOATT] [date] NULL,
	[NENASARCO] [nvarchar](12) NULL,
	[IMPRFAM] [bit],
	[CONDFAM] [bit],
	[DEDART13] [bit],
	[ESILOR] [bit],
	[NAPP] [float] NULL,
	[RAPPR] [float] NULL,
	[CARRAPP] [float] NULL,
	[DECCARINT] [date] NULL,
	[REGSTATSP] [bit],
	[FIRMAT] [float] NULL,
	[AZCONIUG] [bit],
	[MESIREDD] [float] NULL,
	[CODSTAT1] [nvarchar](7) NULL,
	[CODSTAT2] [nvarchar](7) NULL,
	[CODSTAT3] [nvarchar](7) NULL,
	[RICSUP20%] [bit],
	[REGMAG] [bit],
	[DENEST1] [nvarchar](70) NULL,
	[DENEST2] [nvarchar](70) NULL,
	[DENEST3] [nvarchar](70) NULL,
	[AUTSTR] [nvarchar](50) NULL,
	[VALUTA] [nvarchar](3) NULL,
	[PRESELEN] [bit],
	[CESSIVA] [bit],
	[FREQCES] [nvarchar](1) NULL,
	[FREQACQ] [nvarchar](1) NULL,
	[TIPOSOGDEL] [nvarchar](1) NULL,
	[CODSOGDEL] [float] NULL,
	[NONOBBSTAT] [bit],
	[INTCAF] [nvarchar](10) NULL,
	[DICHP] [nvarchar](1) NULL
) ON [PRIMARY];
	
IF OBJECT_ID('dbo.attiv','U') IS NOT NULL DROP TABLE dbo.attiv;
CREATE TABLE [dbo].[attiv](
	[_ID_] [int] IDENTITY(1,1) NOT NULL,	
	[CODDITTA] [float] NULL,
	[CODATT] [nvarchar](5) NULL,
	[ATTPREV] [bit],
	[REGAGR] [bit],
	[REG74TER] [bit],
	[ATTSTAG] [bit],
	[ESLUOGHID] [bit],
	[DCESSATT] [date] NULL,
	[DESCR] [nvarchar](40) NULL,
	[COMCS] [nvarchar](4) NULL,
	[INDCS] [nvarchar](35) NULL,
	[CIVCS] [nvarchar](10) NULL,
	[CAPCS] [nvarchar](5) NULL,
	[PTELCS] [nvarchar](10) NULL,
	[TELCS] [nvarchar](30) NULL,
	[TIPOADS] [nvarchar](1) NULL,
	[CODANGRDS] [float] NULL,
	[TSCRPARZ] [bit],
	[DATAISCIVA] [date] NULL,
	[DATAVARIVA] [date] NULL,
	[CODULIVA11] [float] NULL,
	[OLDCODATT] [float] NULL,
	[SUBCOD] [float] NULL,
	[GIATTANN] [float] NULL,
	[GILAVASTAG] [float] NULL,
	[NSOCILDIP] [float] NULL,
	[ATTSCORTER] [bit],
	[MEDCONV] [bit],
	[ATTLAVDIP] [bit],
	[ART74_4] [bit],
	[TIPOATT] [nvarchar](1) NULL,
	[CODATECO] [nvarchar](6) NULL
) ON [PRIMARY];
	
IF OBJECT_ID('dbo.unloc','U') IS NOT NULL DROP TABLE dbo.unloc;
CREATE TABLE [dbo].[unloc](
	[_ID_] [int] IDENTITY(1,1) NOT NULL,	
	[CODDITTA] [float] NULL,
	[CODULC] [float] NULL,
	[COMULC] [nvarchar](4) NULL,
	[INDULC] [nvarchar](35) NULL,
	[CAPULC] [nvarchar](5) NULL,
	[CIVULC] [nvarchar](10) NULL,
	[NUMCCIAA] [float] NULL,
	[COMCCIAA] [nvarchar](4) NULL,
	[DATAICCIAA] [date] NULL,
	[DATAVCCIAA] [date] NULL,
	[NUMREC] [float] NULL,
	[AUTCOM] [float] NULL,
	[AUTPS] [float] NULL,
	[ALTAUT] [float] NULL,
	[POSINPS] [nvarchar](13) NULL,
	[POSINAIL] [nvarchar](11) NULL,
	[REGIMP] [nvarchar](19) NULL,
	[COMTRIB] [nvarchar](4) NULL,
	[CAPTRIB] [nvarchar](5) NULL,
	[MQULC] [float] NULL,
	[MQULCMAG] [float] NULL
) ON [PRIMARY];
	
	
IF OBJECT_ID('dbo.comuni','U') IS NOT NULL DROP TABLE dbo.comuni;
CREATE TABLE [dbo].[comuni](
	[_ID_] [int] IDENTITY(1,1) NOT NULL,
	[STATO] [nvarchar](3) NULL,
	[COM] [nvarchar](4) NULL,
	[DENCOM] [nvarchar](50) NULL,
	[PROVCOM] [nvarchar](5) NULL,
	[CODREG] [float] NULL,
	[CAPCOM] [nvarchar](5) NULL,
	[CODISTAT] [float] NULL,
	[UFFIIDD1] [float] NULL,
	[UFFIIDD2] [float] NULL,
	[UFFIIDD3] [float] NULL,
	[UFFIVA1] [float] NULL,
	[UFFIVA2] [float] NULL,
	[UFFIVA3] [float] NULL,
	[UFFREG] [nvarchar](3) NULL,
	[UFFCONC] [float] NULL,
	[UFFCSERV] [float] NULL,
	[UFFESPROV] [float] NULL,
	[UFFESCOM] [float] NULL,
	[ALIQICI] [float] NULL,
	[COMAGG] [nvarchar](4) NULL,
	[TERRMON] [float] NULL,
	[CODUUE1] [float] NULL,
	[CODUUE2] [float] NULL,
	[CODUUE3] [float] NULL,
	[CODUUE4] [float] NULL,
	[CODUUE5] [float] NULL,
	[CODUUE6] [float] NULL,
	[CODUUE7] [float] NULL,
	[CODUUE8] [float] NULL,
	[CODUUE9] [float] NULL,
	[CODUUE10] [float] NULL
	) ON [PRIMARY];


