在Sql Server中创建一个触发器,提示before不是可以识别的触发器,怎么解决?

2024-12-17 10:22:42
推荐回答(2个)
回答1:

标准的创建触发器语言里面没有before,只有for

SQL触发器语法

  语法
  CREATE TRIGGER trigger_name
  ON { table | view }
  [ WITH ENCRYPTION ]
  {
  { { FOR | AFTER | INSTEAD OF } { [ INSERT ] [ DELETE ] [ UPDATE ] }
  [ WITH APPEND ]
  [ NOT FOR REPLICATION ]
  AS
  [ { IF UPDATE ( column )
  [ { AND | OR } UPDATE ( column ) ]
  [ ...n ]
  | IF ( COLUMNS_UPDATED ( ) updated_bitmask )
  column_bitmask [ ...n ]
  } ]
  sql_statement [ ...n ]
  }
  }

回答2:

BEFORE 改成FOR