Как мы можем использовать значение сеанса в триггере в SQL server 2012 и вставить его в таблицу?
How can we use session value in trigger in SQL Server 2012 and insert into a table? I created a session but getting confuse, how can i use session value into a trigger. I'm creating a log table for view all logs that which action is acted in main table. and please tell me how can I update table with update Trigger with new session value and ID fetch from main table to update data. In given code @ActionBy value I want from new session. How can I do this? Please let me know about this.
Что я уже пробовал:
CREATE TRIGGER EpaperTrgrUpdate ON EPaper AFTER INSERT AS BEGIN SET NOCOUNT ON; DECLARE @EpaperId INT DECLARE @Date datetime DECLARE @ActionBy nvarchar(50) DECLARE @Action varchar(50) SELECT @EpaperId = EPaper.SrNo, @Date = date, @ActionBy = EPaper.ActionBy FROM EPaper IF UPDATE(IMG) BEGIN SET @Action = 'Image Updated' END IF UPDATE(Date) BEGIN SET @Action = 'Date Updated' END INSERT INTO Epaper_Log VALUES(@EpaperId, @Date, @Action, @ActionBy) END