SQL Server 2014中的更新触发器

时间:2019-01-17 15:41:30

标签: sql-server-2014 database-trigger

我有用于将T_PDF表中的记录插入T_WV_RESULT的插入触发器。当在T_PDF表中插入新记录时会触发以下触发器。现在我需要以下触发器更新

T_PDF表结构

a.add(b)

T_WV_RESULT表结构

CREATE TABLE [dbo].[T_PDF](
    [F_PRODUCT] [varchar](50) NOT NULL,
    [F_LANGUAGE] [varchar](2) NOT NULL,
    [F_FORMAT] [varchar](3) NOT NULL,
    [F_SUBFORMAT] [varchar](4) NOT NULL,
    [F_DATE_STAMP] [datetime] NOT NULL,
    [F_PLANT] [varchar](10) NOT NULL,
    [F_SUPPLIER] [varchar](200) NOT NULL,
    [F_PRODUCT_NAME] [nvarchar](2000) NULL,
    [F_DATE_REVISED] [datetime] NULL,
    [F_PDF] [varbinary](max) NULL,
    [F_AUTHORIZED] [smallint] NULL,
    [F_Published_Date] [datetime] NULL,
    [F_CAS_NUMBERS] [varchar](4000) NULL,
    [F_COMPONENT_IDS] [varchar](4000) NULL,
    [F_ISSUE_DATE] [datetime] NULL,
    [F_DISPOSAL_DATE] [datetime] NULL,
    [F_DOC_TYPE] [smallint] NOT NULL,
    [F_DOC_PATH] [varchar](200) NULL,
    [F_KEYWORDS] [varchar](255) NULL,
    [F_CUSTOM1] [nvarchar](4000) NULL,
    [F_CUSTOM2] [nvarchar](4000) NULL,
    [F_CUSTOM3] [nvarchar](4000) NULL,
    [F_CUSTOM4] [nvarchar](4000) NULL,
    [F_CUSTOM5] [nvarchar](4000) NULL,
    [F_GUID] [uniqueidentifier] NULL,
    [F_User_Updated] [varchar](15) NULL,
    [F_REV_NUM] [real] NULL,
    [F_IS_S3] [bit] NULL,
    [F_COUNTER] [int] IDENTITY(1,1) NOT NULL,
 CONSTRAINT [PK_T_PDF] PRIMARY KEY CLUSTERED 
(
    [F_PRODUCT] ASC,
    [F_LANGUAGE] ASC,
    [F_FORMAT] ASC,
    [F_SUBFORMAT] ASC,
    [F_DATE_STAMP] ASC,
    [F_PLANT] ASC,
    [F_DOC_TYPE] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, FILLFACTOR = 80) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO

插入触发器

CREATE TABLE [dbo].[T_WV_RESULT](
    [ID] [varchar](50) NULL,
    [NAME] [nvarchar](2000) NULL,
    [FMTCODE] [varchar](3) NULL,
    [SFMTCODE] [varchar](4) NULL,
    [SFMT] [varchar](30) NULL,
    [LANGCODE] [varchar](2) NULL,
    [LANG] [varchar](50) NULL,
    [PLANTCODE] [varchar](10) NULL,
    [RDATE] [datetime] NULL,
    [CASNUM] [varchar](4000) NULL,
    [TN] [varchar](4000) NULL,
    [CP] [varchar](4000) NULL,
    [CUS5] [varchar](4000) NULL,
    [MANU] [varchar](max) NULL,
    [SYN] [nvarchar](4000) NULL,
    [ICO] [nvarchar](4000) NULL,
    [DOC] [varchar](2000) NULL,
    [COVER] [varchar](100) NULL,
    [GUID] [varchar](256) NULL,
    [SDS] [varchar](4) NULL,
    [SITECODE] [varchar](8) NULL,
    [PDATE] [datetime] NULL,
    [CASDATA] [varchar](4000) NULL,
    [CUS3] [varchar](4000) NULL
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO

它还包含一些子查询。如果我对它反映在T_WV_Result表中的表中进行任何更改,该如何编写更新触发器?

0 个答案:

没有答案