IF NOT EXISTS (SELECT 1 FROM sysobjects WHERE name = 'PREPARETABLENAME')
BEGIN
    CREATE TABLE PREPARETABLENAME (
        [id] INT IDENTITY NOT NULL,
        [code20] CHAR (20) NOT NULL,
        [prodsubtype] CHAR (10) NOT NULL,
        [resprodcode] VARCHAR (13) NOT NULL,
        [codelv] tinyint NOT NULL,
        [fileid] INTEGER NOT NULL,
        [status] tinyint NOT NULL DEFAULT 0,
        [updatepc] VARCHAR (10) NULL,
        [taskid] INTEGER,
        [vbatch] VARCHAR (20),
        [firsttime] datetime DEFAULT getdate() NOT NULL,
        [lasttime] datetime DEFAULT getdate(),
        PRIMARY KEY NONCLUSTERED ( [code20] )
    )
    CREATE CLUSTERED INDEX [IX_PREPARETABLENAME_FILEID] ON [dbo].PREPARETABLENAME ( [fileid] ASC ) WITH (
        PAD_INDEX = OFF,
        STATISTICS_NORECOMPUTE = OFF,
        SORT_IN_TEMPDB = OFF,
        IGNORE_DUP_KEY = OFF,
        DROP_EXISTING = OFF,
        ONLINE = OFF,
        ALLOW_ROW_LOCKS = ON,
        ALLOW_PAGE_LOCKS = ON
    ) ON [PRIMARY]
    CREATE NONCLUSTERED INDEX [IX_PREPARETABLENAME_1] ON PREPARETABLENAME ( [resprodcode] ASC ) WITH (
        PAD_INDEX = OFF,
        STATISTICS_NORECOMPUTE = OFF,
        SORT_IN_TEMPDB = OFF,
        IGNORE_DUP_KEY = OFF,
        DROP_EXISTING = OFF,
        ONLINE = OFF,
        ALLOW_ROW_LOCKS = ON,
        ALLOW_PAGE_LOCKS = ON
    ) ON [PRIMARY]
END