CREATE TABLE [dbo].[Celle] ( [IdxCella] INT IDENTITY (1, 1) NOT NULL, [CodCS] NCHAR (2) NOT NULL, [CodCella] NVARCHAR (50) NOT NULL, [IdxTipoCella] INT NULL, [Descrizione] NVARCHAR (50) NULL, [Attiva] BIT NULL, [Piena] BIT CONSTRAINT [DF_Celle_Piena] DEFAULT ((0)) NOT NULL, [IdxBlocco] INT CONSTRAINT [DF_Celle_IdxBlocco] DEFAULT ((0)) NOT NULL, [X] INT NOT NULL, [Y] INT NOT NULL, [Z] INT NOT NULL, CONSTRAINT [PK_Celle] PRIMARY KEY CLUSTERED ([IdxCella] ASC), CONSTRAINT [FK_Celle_Blocchi] FOREIGN KEY ([IdxBlocco]) REFERENCES [dbo].[Blocchi] ([IdxBlocco]) ON UPDATE CASCADE, CONSTRAINT [FK_Celle_TipoCella] FOREIGN KEY ([IdxTipoCella]) REFERENCES [dbo].[TipoCella] ([IdxTipoCella]) ); GO CREATE NONCLUSTERED INDEX [IX_Celle_Attiva_IdxBlocco] ON [dbo].[Celle]([Attiva] ASC, [IdxBlocco] ASC); GO EXECUTE sp_addextendedproperty @name = N'MS_Description', @value = N'indica se sia attiva, se non lo fosse è impedito caricamento nella stessa', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'Celle', @level2type = N'COLUMN', @level2name = N'Attiva'; GO EXECUTE sp_addextendedproperty @name = N'MS_Description', @value = N'posizione X (colonna)', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'Celle', @level2type = N'COLUMN', @level2name = N'X'; GO EXECUTE sp_addextendedproperty @name = N'MS_Description', @value = N'posizione Y (livello/ripiano)', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'Celle', @level2type = N'COLUMN', @level2name = N'Y'; GO EXECUTE sp_addextendedproperty @name = N'MS_Description', @value = N'posizione Z (profondita)', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'Celle', @level2type = N'COLUMN', @level2name = N'Z';