在SQL Server Management Studio 2014中,禁用“新建触发器”菜单选项

时间:2014-11-11 17:19:56

标签: sql-server sql-server-2008-r2 sql-server-express triggers management-studio-express

enter image description here

我想在我的桌子上添加一个新的触发器。如图所示,“新建触发器”按钮未激活。新指数,新栏目,新约束,新静力学活跃。

我不明白这是什么问题。

2 个答案:

答案 0 :(得分:19)

您无需使用菜单项来创建触发器。只需打开一个查询窗口并在那里写下create trigger语句。

要获得语法方面的帮助,您可以在编辑器中使用代码段。右键单击查询编辑器的表面并选择“插入片段”,然后选择“触发器”和“创建触发器”以将以下代码段插入编辑器。

CREATE TRIGGER TriggerName
    ON [dbo].[TableName]
    FOR DELETE, INSERT, UPDATE
    AS
    BEGIN
    SET NOCOUNT ON
    END

菜单项(如果你让它工作)会做几乎相同的事情,只会使用看起来像这样的模板:

-- ================================================
-- Template generated from Template Explorer using:
-- Create Trigger (New Menu).SQL
--
-- Use the Specify Values for Template Parameters 
-- command (Ctrl-Shift-M) to fill in the parameter 
-- values below.
--
-- See additional Create Trigger templates for more
-- examples of different Trigger statements.
--
-- This block of comments will not be included in
-- the definition of the function.
-- ================================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author:      <Author,,Name>
-- Create date: <Create Date,,>
-- Description: <Description,,>
-- =============================================
CREATE TRIGGER <Schema_Name, sysname, Schema_Name>.<Trigger_Name, sysname, Trigger_Name> 
   ON  <Schema_Name, sysname, Schema_Name>.<Table_Name, sysname, Table_Name> 
   AFTER <Data_Modification_Statements, , INSERT,DELETE,UPDATE>
AS 
BEGIN
    -- SET NOCOUNT ON added to prevent extra result sets from
    -- interfering with SELECT statements.
    SET NOCOUNT ON;

    -- Insert statements for trigger here

END
GO

答案 1 :(得分:2)

此处提出了类似的问题:SQL Server Express 'NEW TRIGGER' BUTTON IS DISABLED

我希望这可以帮到你!