开发者

Update Trigger in sql server

Hi Experts I have table in sql server. and i want to apply update trigger on that. i want to update the same table that have trigger. can any one help me to with exampl开发者_如何学Pythone.


You can find this code in SQL Server Management Studio Template Explorer

--======================================
--  Create T-SQL Trigger Template
--======================================
USE <database_name, sysname, AdventureWorks>
GO

IF OBJECT_ID ('<schema_name, sysname, Sales>.<trigger_name, sysname, uStore>','TR') IS NOT NULL
   DROP TRIGGER <schema_name, sysname, Sales>.<trigger_name, sysname, uStore> 
GO

CREATE TRIGGER <schema_name, sysname, Sales>.<trigger_name, sysname, uStore> 
   ON  <schema_name, sysname, Sales>.<table_name, sysname, Store> 
   AFTER <data_modification_statements, , UPDATE>
AS <T-SQL_statement, , UPDATE Sales.Store SET ModifiedDate = GETDATE() FROM inserted WHERE inserted.CustomerID = Sales.Store.CustomerID>
GO

A simple example being

CREATE TRIGGER TriggerName ON TableName
    AFTER UPDATE
AS
    /* Some SQL Statements */
    UPDATE  TableName
    SET     ColumnName = 'SomeText'

GO
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜