我们公司用了两个公司的数据库,一个是考勤系统本身,一个是考勤软件。
它们两个需要共享一些数据,为了达到实时的目的,我想到了触发器,即,考勤系统打卡时,考勤软件系统直接得到数据;
以下是三个表:
括号内为需要的字段名:
RecDB.dbo.MJ_IOData (CardNo,IOdateTime)
GM_MT.dbo.GM_KQ_Employee (EmployeeID,CardNum)
GM_MT.dbo.GM_KQ_TimeRecorderData(EmployeeID,BuildDateTime)触发器编写如下:CREATE trigger insertemployee
on RecDB.dbo.MJ_IOData
FOR insert
as begin
insert into GM_MT.dbo.GM_KQ_TimeRecorderData(EmployeeID,BuildDateTime)
SELECT GM_MT.dbo.GM_KQ_Employee.EmployeeID,RecDB.dbo.MJ_IOData.IOdateTime From RecDB.dbo.MJ_IOData,GM_MT.dbo.GM_KQ_Employee where RecDB.dbo.MJ_IOData.CardNo=GM_MT.dbo.GM_KQ_Employee.CardNum and RecDB.dbo.MJ_IOData.IOdateTime not in(select distinct GM_MT.dbo.GM_KQ_TimeRecorderData.BuildDateTime from GM_MT.dbo.GM_KQ_TimeRecorderData) end
现在的问题是,我一打卡,考勤系统就提示写入数据表出错,请朋友们帮忙解决一下。
它们两个需要共享一些数据,为了达到实时的目的,我想到了触发器,即,考勤系统打卡时,考勤软件系统直接得到数据;
以下是三个表:
括号内为需要的字段名:
RecDB.dbo.MJ_IOData (CardNo,IOdateTime)
GM_MT.dbo.GM_KQ_Employee (EmployeeID,CardNum)
GM_MT.dbo.GM_KQ_TimeRecorderData(EmployeeID,BuildDateTime)触发器编写如下:CREATE trigger insertemployee
on RecDB.dbo.MJ_IOData
FOR insert
as begin
insert into GM_MT.dbo.GM_KQ_TimeRecorderData(EmployeeID,BuildDateTime)
SELECT GM_MT.dbo.GM_KQ_Employee.EmployeeID,RecDB.dbo.MJ_IOData.IOdateTime From RecDB.dbo.MJ_IOData,GM_MT.dbo.GM_KQ_Employee where RecDB.dbo.MJ_IOData.CardNo=GM_MT.dbo.GM_KQ_Employee.CardNum and RecDB.dbo.MJ_IOData.IOdateTime not in(select distinct GM_MT.dbo.GM_KQ_TimeRecorderData.BuildDateTime from GM_MT.dbo.GM_KQ_TimeRecorderData) end
现在的问题是,我一打卡,考勤系统就提示写入数据表出错,请朋友们帮忙解决一下。
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货