Never found a clear example online of simply updating a database's modification date with when a row is changed so I thought I would post one:
=======================
CREATE TRIGGER [dbo].[TRG_{TABLE-NAME}_Update_ModificationDate] ON [dbo].[{TABLE-NAME}]
AFTER UPDATE
AS
DECLARE @{UNIQUE-COLUMNNAME} [uniqueidentifier]
SELECT @{UNIQUE-COLUMNNAME} = i.{UNIQUE-COLUMNNAME} FROM inserted i
UPDATE {TABLE-NAME}
SET Modification_Date = GETDATE()
WHERE {UNIQUE-COLUMNNAME} = @{UNIQUE-COLUMNNAME};
========================
Legend:
{TABLE-NAME} = Name of Table to create the SQL Server Trigger on.
{UNIQUE-COLUMNNAME} = Name of Column in table above that uniquely identifies a row.
Showing posts with label SQL Server. Show all posts
Showing posts with label SQL Server. Show all posts
Wednesday, May 15, 2013
Wednesday, June 13, 2007
SQL Server 2008: Geo Data Types
Here's a post regarding the upcoming version of SQL 2008 that states it will support a new data type: Geo Data.
Subscribe to:
Posts (Atom)