Disable Enable Trigger SQL server for a table

后端 未结 7 1828
粉色の甜心
粉色の甜心 2020-12-12 14:24

I want to create one proc like below but it has error on syntax. Could anyone pointing out the problem?

Create PROCEDURE [dbo].[my_proc] AS

BEGIN

DISABLE T         


        
相关标签:
7条回答
  • 2020-12-12 15:07

    The line before needs to end with a ; because in SQL DISABLE is not a keyword. For example:

    BEGIN
    ;
    DISABLE TRIGGER ...
    
    0 讨论(0)
  • 2020-12-12 15:08

    Below is the simplest way

    Try the code

    ALTER TRIGGER trigger_name DISABLE

    That's it :)

    0 讨论(0)
  • 2020-12-12 15:09

    As Mark mentioned, the previous statement should be ended in semi-colon. So you can use:

    ; DISABLE TRIGGER dbo.tr_name ON dbo.table_name
    
    0 讨论(0)
  • 2020-12-12 15:11

    use the following commands instead:

    ALTER TABLE table_name DISABLE TRIGGER tr_name
    
    ALTER TABLE table_name ENABLE TRIGGER tr_name
    
    0 讨论(0)
  • 2020-12-12 15:13

    After the ENABLE TRIGGER OR DISABLE TRIGGER in a new line write GO, Example:

    DISABLE TRIGGER dbo.tr_name ON dbo.table_name
    
    GO
    -- some update statement
    
    ENABLE TRIGGER dbo.tr_name  ON dbo.table_name
    
    GO
    
    0 讨论(0)
  • 2020-12-12 15:18

    if you want to execute ENABLE TRIGGER Directly From Source :

    we can't write like this:

    Conn.Execute "ENABLE TRIGGER trigger_name ON table_name"
    

    instead, we can write :

    Conn.Execute "ALTER TABLE table_name DISABLE TRIGGER trigger_name"
    
    0 讨论(0)
提交回复
热议问题