IF NOT EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID('[dbo].[mps_flowworkstatus_data]') AND type = 'U')
CREATE TABLE [dbo].[mps_flowworkstatus_data]
(
    [wsd_id] int NOT NULL IDENTITY(1, 1),
    [wsd_wsid] int NULL DEFAULT((0)),
    [wsd_tobjtype] varchar(20) COLLATE Chinese_PRC_CI_AS NULL DEFAULT(''),
    [wsd_tobjid] int NULL DEFAULT((0)),
    [wsd_tobjid2] int NULL DEFAULT((0)),
    [wsd_sord2tag] int NULL DEFAULT((0)),
    [wsd_updatesql] nvarchar(max) COLLATE Chinese_PRC_CI_AS NULL DEFAULT(''),
    [wsd_sql] nvarchar(max) COLLATE Chinese_PRC_CI_AS NULL DEFAULT(''),
    [wsd_use] int NULL DEFAULT((0)),
    [wsd_keyfield] varchar(50) COLLATE Chinese_PRC_CI_AS NULL DEFAULT(''),
    CONSTRAINT [PK_MPS_FLOWWORKSTATUS_DATA] PRIMARY KEY ([wsd_id] ASC)
)

ALTER TABLE [dbo].[mps_flowworkstatus_data] WITH CHECK ADD CONSTRAINT [FK_MPS_FLOW_REFERENCE_MPS_FLOW_DTA] FOREIGN KEY ([wsd_wsid]) REFERENCES [dbo].[mps_flowworkstatus] ([ws_id]) ON DELETE CASCADEALTER TABLE [dbo].[mps_flowworkstatus_data] CHECK CONSTRAINT [FK_MPS_FLOW_REFERENCE_MPS_FLOW_DTA]