Title: INSERT_TBST_TARecords                                 If you need copy same format use firefox or chrome or safari but iexplorer not work


Preview of Code
sql server
USE [TBS_BAWSE]
GO
/****** Object:  Trigger [dbo].[TRI_INSERT_TBST_TARecords]    Script Date: 09/05/2016 09:02:49 ص ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER  TRIGGER [dbo].[TRI_INSERT_TBST_TARecords]
   ON  [TBS_BAWSE].[dbo].[TBST_TARecords]
   AFTER  INSERT
AS 
BEGIN
SET NOCOUNT ON;
declare @inout int;
declare @inoutInt nvarchar(50);
 
select @inout = [TA_IDContext]  from inserted;
 
-- set @inoutInt = 255;
 
if @inout = 100
begin
set @inoutInt = `IN`;
end
 
if @inout = 200
begin
set @inoutInt =  `OUT`;
end
 
if @inout = 0
begin
set @inoutInt =  `F1`;
end
 
 
 
INSERT OPENQUERY (HR12, `SELECT  ID ,EMPID,EVENTID,TERMINALSN,RECLOGFROMIP,LOCAL_TIMESTAMP_DATE,LOCAL_TIMESTAMP_TIME FROM HRGVUSER.T_HRGV_EVENT_LOGS`)
select  i.[TA_UID],
        i.[TA_UserID],
        @inoutInt,
        i.TA_Timestamp,                        --i.[TA_IDContext],
        i.[TA_AccessPointID],
        i.[TA_LocalTimestamp],
        i.[TA_LocalTimestamp]
 from  inserted i;      
  
 
END