IF NOT EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID('[dbo].[mps_alarm]') AND type = 'U')
CREATE TABLE [dbo].[mps_alarm]
(
    [alm_id] int NOT NULL IDENTITY(1, 1),
    [alm_cmpid] int NULL DEFAULT((0)),
    [alm_title] nvarchar(100) COLLATE Chinese_PRC_CI_AS NULL DEFAULT(''),
    [alm_objtype] varchar(30) COLLATE Chinese_PRC_CI_AS NULL DEFAULT(''),
    [alm_objid] int NULL DEFAULT((0)),
    [alm_objid2] int NULL DEFAULT((0)),
    [alm_category] nvarchar(100) COLLATE Chinese_PRC_CI_AS NULL DEFAULT(''),
    [alm_tmpid] int NULL DEFAULT((0)),
    [alm_tmpcaption] nvarchar(100) COLLATE Chinese_PRC_CI_AS NULL DEFAULT(''),
    [alm_tobizid] int NULL DEFAULT((0)),
    [alm_biztitle] nvarchar(100) COLLATE Chinese_PRC_CI_AS NULL DEFAULT(''),
    [alm_createmode] int NULL DEFAULT((0)),
    [alm_sql] nvarchar(max) COLLATE Chinese_PRC_CI_AS NULL DEFAULT(''),
    [alm_identkey] nvarchar(100) COLLATE Chinese_PRC_CI_AS NULL DEFAULT(''),
    CONSTRAINT [PK_mps_alarm] PRIMARY KEY ([alm_id] ASC)
)

IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE object_id = OBJECT_ID('[dbo].[mps_alarm]') AND name = 'mps_alarm_index')
CREATE NONCLUSTERED INDEX [mps_alarm_index] ON [dbo].[mps_alarm]([alm_cmpid] ASC)

IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE object_id = OBJECT_ID('[dbo].[mps_alarm]') AND name = 'mps_alarm_index')
CREATE NONCLUSTERED INDEX [mps_alarm_index] ON [dbo].[mps_alarm]([alm_title] ASC)