CREATE TABLE [dbo].[ElencoAssiemi] (
    [AL]           NVARCHAR (50) NOT NULL,
    [TipoAL]       AS            (substring([AL],(3),(1))),
    [Numero]       AS            (substring([AL],(6),(5))),
    [Cesta]        AS            (substring([AL],(11),(4))),
    [Attivo]       BIT           CONSTRAINT [DF_ElencoAssiemi_Attivo] DEFAULT ((1)) NOT NULL,
    [DataCreaz]    DATETIME      CONSTRAINT [DF_ElencoAssiemi_DataCreaz] DEFAULT (getdate()) NOT NULL,
    [CodSoggetto]  NCHAR (17)    CONSTRAINT [DF_ElencoAssiemi_CodSoggetto] DEFAULT ('') NOT NULL,
    [CodDtx_start] NVARCHAR (50) CONSTRAINT [DF_ElencoAssiemi_CodDtx_start] DEFAULT ('') NOT NULL,
    [CodDtx_end]   NVARCHAR (50) CONSTRAINT [DF_ElencoAssiemi_CodDtx_end] DEFAULT ('') NOT NULL,
    CONSTRAINT [PK_ElencoAssiemi] PRIMARY KEY CLUSTERED ([AL] ASC)
);


GO
EXECUTE sp_addextendedproperty @name = N'MS_Description', @value = N'primo datamatrix letto', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'ElencoAssiemi', @level2type = N'COLUMN', @level2name = N'CodDtx_start';


GO
EXECUTE sp_addextendedproperty @name = N'MS_Description', @value = N'numero progressivo (R) o di trattamento (T)', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'ElencoAssiemi', @level2type = N'COLUMN', @level2name = N'Numero';


GO
EXECUTE sp_addextendedproperty @name = N'MS_Description', @value = N'Codice univoco ', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'ElencoAssiemi', @level2type = N'COLUMN', @level2name = N'AL';


GO
EXECUTE sp_addextendedproperty @name = N'MS_Description', @value = N'tipologia R (pre tratt) / T (trattata)', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'ElencoAssiemi';

