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
精彩评论