I have write Trigger but this is not working in
I have used after inserting data that time "userId " not getting .
- GO
- /****** Object: Trigger [dbo].[insertCheckInOutTrigger] Script Date: 2019-07-15 11:24:57 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
-
-
- alter TRIGGER [dbo].[insertCheckInOutTrigger]
- ON [dbo].[tbl_InOutUser]
- AFTER INSERT
- AS
- BEGIN
- SET NOCOUNT ON;
-
- DECLARE
- @Id INT,
- @checktype bit,
- @date datetime,
- @userId int,
- @createdDate datetime,
- @createdBy INT,
- @EmpId INT,
- @SN nvarchar(20),
- @Sah_UserId INT,
- @UserSN nvarchar(20),
- @SS nvarchar(20),
- @idstring nvarchar(20)
-
- SELECT
- @Id =[Id],
- @checktype =[CheckType],
- @date =[Date],
- @userId =[UserId],
- @createdDate= [CreatedDate],
- @createdBy =[CreatedBy]
- FROM [dbo].[tbl_InOutUser]
-
-
-
- SELECT
- @EmpId =[EmployeeId]
- FROM [User]
- WHERE id=@userId
-
-
- SELECT @Sah_UserId=[userid] ,@SN=[SN]
- from [192.168.11.213].adms.[dbo].[userinfo]
- WHERE CONVERT(int , badgenumber)=CONVERT(int, @EmpId)
-
-
- SELECT TOP 1 @UserSN=[SN]
- from [192.168.11.213].adms.[dbo].checkinout where userid=@Sah_UserId and CONVERT(date, checktime)=CONVERT(date, getdate());
-
-
-
- INSERT INTO [192.168.11.213].adms.[dbo].checkinout
- (userid,checktime,checktype,verifycode,SN,sensorid,WorkCode,Reserved)
- VALUES(1021,@date,'1','1',case when @UserSN is null then @SN else @UserSN end,'1',null,null)
-
-
-
-
-
- END
-
-
-
-
-
-
-
-
-
-
-
please help me..