FITOMN of AM v3
3/14/2017 - 4:47 PM

Creación de Trigger en Cat_Alumnos para replicar información insertada en Cat_BitacoraUsuarios

Creación de Trigger en Cat_Alumnos para replicar información insertada en Cat_BitacoraUsuarios

/* --------------------------------------------------------------------------------------------------------------
FECHA		   |    AUTOR		|DESCRIPCION
14/Mar/2017    | Luis Bernal	|
--------------------------------------------------------------------------------------------------------------*/

SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO

CREATE TRIGGER TRG_InsercionCatAlumnos
   ON  dbo.Cat_Alumnos
   AFTER INSERT
AS 
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET DATEFIRST 7;
	SET NOCOUNT ON;
	SET DATEFORMAT MDY;
	SET LANGUAGE spanish;

    -- Insert statements for trigger here
	INSERT INTO dbo.Cat_BitacoraUsuarios
			( idOriginal ,
			  iTipoUsuario ,
			  sNombre ,
			  sObservaciones ,
			  dfecha
			)
	SELECT idAlumno, 3 AS iTipoUsuario, (sApellidoPaterno + ' ' + sApellidoMaterno + ' ' + sNombre) AS sNombre , ('Matricula|' + sMatricula + '|') AS sObservaciones, GETDATE() AS dFecha
	FROM Inserted
	
END
GO