Skip to content

Instantly share code, notes, and snippets.

@ebenito
Created March 6, 2019 07:56
Show Gist options
  • Save ebenito/200aa860b3333e3e1770b4c49362a233 to your computer and use it in GitHub Desktop.
Save ebenito/200aa860b3333e3e1770b4c49362a233 to your computer and use it in GitHub Desktop.
Trigger para capturar usuario y fecha y hora de modificación
CREATE TRIGGER [dbo].[NombreTrigger_UpdIns] ON [dbo].[NombreTabla]
FOR UPDATE, INSERT AS
UPDATE NombreTabla
SET UserName = coalesce(suser_sname(),'?'),
UserDateTime = GETDATE()
WHERE id IN (SELECT DISTINCT id FROM Inserted)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment