Create Trigger in SQL Server

前端 未结 3 885
后悔当初
后悔当初 2020-12-11 02:29

I got lost when I wanted to create trigger using the pre-defined \"CREATE TRIGGER\" of SQL Server 2008 R2. Could you please give me a direct SQL statement that I can use to

3条回答
  •  感动是毒
    2020-12-11 02:40

    The basic syntax is

    CREATE TRIGGER YourTriggerName ON dbo.YourTable
    FOR|AFTER INSERT, UPDATE, DELETE
    AS
    BEGIN
         /*Put what ever you want here*/
         UPDATE AnotherTable
              SET SomeColumn = AnotherColumn
         FROM inserted | deleted
    END
    GO
    

提交回复
热议问题