USE [Arizona];
BEGIN TRANSACTION;
SET XACT_ABORT ON;

IF NOT EXISTS(
    SELECT * 
    FROM [sys].[tables] [t]
    WHERE [t].[name] = 'CCI_item'
    AND SCHEMA_NAME([t].[schema_id]) = 'dbo'
)
BEGIN
    CREATE TABLE [dbo].[CCI_item]
    (
    [CCI_item_ID] [dbo].[Unique_identifier] NOT NULL,
    [CCIIT_item] [dbo].[Unique_identifier] NOT NULL,
    [CCIIT_predefined_entry] [dbo].[Unique_identifier] NOT NULL,
    [CCIIT_sequence] [dbo].[Sequence_numbers] NULL,
    [CCIIT_print_sequence] [dbo].[Small_alphabetical_field] NULL,
    [CCIIT_TS] [timestamp] NOT NULL,
    [CCIIT_VGUID] [dbo].[VGUID_identifier] NULL CONSTRAINT [DF__CCI_item__CCIIT___77EF7824] DEFAULT (NEWID()),
    [CCIIT_master_ID] [dbo].[Large_name_field] NULL
    ) ON [PRIMARY];
    ALTER TABLE [dbo].[CCI_item] ADD CONSTRAINT [PK__CCI_item__53385258] PRIMARY KEY NONCLUSTERED ([CCI_item_ID]) WITH (FILLFACTOR=90) ON [PRIMARY];
    CREATE NONCLUSTERED INDEX [XIF1852CCI_item] ON [dbo].[CCI_item] ([CCIIT_predefined_entry]) WITH (FILLFACTOR=90) ON [PRIMARY];
    CREATE NONCLUSTERED INDEX [XIF1853CCI_item] ON [dbo].[CCI_item] ([CCIIT_item]) WITH (FILLFACTOR=90) ON [PRIMARY];
    CREATE NONCLUSTERED INDEX [XIEAPS1CCI_item] ON [dbo].[CCI_item] ([CCIIT_VGUID]) WITH (FILLFACTOR=90) ON [PRIMARY];
    CREATE NONCLUSTERED INDEX [XIEAPS2CCI_item] ON [dbo].[CCI_item] ([CCIIT_master_ID]) WITH (FILLFACTOR=90) ON [PRIMARY];
    PRINT 'table is created';
END; 

COMMIT TRANSACTION;
