IF OBJECT_ID(N'dbo.Tw_InputDetailBarCode', N'U') IS NULL
BEGIN
    CREATE TABLE dbo.Tw_InputDetailBarCode
    (
        Id NVARCHAR(50) NOT NULL,
        InputDetailId NVARCHAR(50) NOT NULL,
        InputMasterId NVARCHAR(50) NOT NULL,
        MaterialCode NVARCHAR(50) NULL,
        BarCode NVARCHAR(500) NULL,
        CONSTRAINT PK_Tw_InputDetailBarCode PRIMARY KEY CLUSTERED (Id ASC)
    );

    CREATE NONCLUSTERED INDEX IX_Tw_InputDetailBarCode_InputMasterId
        ON dbo.Tw_InputDetailBarCode(InputMasterId);

    CREATE NONCLUSTERED INDEX IX_Tw_InputDetailBarCode_InputDetailId
        ON dbo.Tw_InputDetailBarCode(InputDetailId);
END;
