数据库A
表  acs_cardevents     empid vachar(20)
                       ftime smalldatetime(4) 数据库B
表   GM_KQ_TimeRecorderData   employeeid vachar(20)
                              BuildDateTime  smalldatetime(4)说明 :empid和employeeid都是员工编码,当ftime增加一条数据时在BuildDateTime也增加一条数据

解决方案 »

  1.   

    create trigger test on acs_cardevents
    for insert
    as
    insert into GM_KQ_TimeRecorderData  select * from inserted
      

  2.   

    declare @EmpID varchar(20),
    @ftime smalldatetime(4)select  @EmpID=empid,
    @ftime=ftime

    from Insertedinsert into GM_KQ_TimeRecorderData(employeeid,BuildDateTime)
    values(@EmpID,@ftime)
      

  3.   

    declare @EmpID varchar(20), 
    @ftime smalldatetime(4) select  @EmpID=empid, 
    @ftime=ftime from Inserted insert into GM_KQ_TimeRecorderData(employeeid,BuildDateTime) 
    values(@EmpID,@ftime)
    提示我GM_KQ_TimeRecorderData这个无效
      

  4.   

    insert into 数据库B.dbo.GM_KQ_TimeRecorderData(employeeid,BuildDateTime)  
    values(@EmpID,@ftime) 
    不在同一个库里要加上数据库的全称
      

  5.   

    create trigger test on acs_cardevents for insert 
    as 
    insert into 数据库B.dbo.GM_KQ_TimeRecorderData(employeeid,BuildDateTime) select * from  inserted
      

  6.   

    数据库A 
    表  acs_cardevents     empid vachar(20) 
                           ftime smalldatetime(4)   数据库B 
    表   GM_KQ_TimeRecorderData   employeeid vachar(20) 
                                  BuildDateTime  smalldatetime(4) 说明 :empid和employeeid都是员工编码,当ftime增加一条数据时在BuildDateTime也增加一条数据郁闷:在empid和employeeid之间的转换的时候要自动增加到6位数,例如在 表  acs_cardevents 中的empid是58163,到了  表   GM_KQ_TimeRecorderData中employeeid要是058163,就是要自动增加到6位,不够的填0
      

  7.   


    改成这样
    insert into 数据库B.dbo.GM_KQ_TimeRecorderData(employeeid,BuildDateTime) 
    select (right('000000'+empid,6),ftime ) from  inserted 
      

  8.   

    数据库A  
    表  acs_cardevents     empid vachar(20)  
                           ftime smalldatetime(4)     数据库B  
    表   GM_KQ_TimeRecorderData   employeeid vachar(20)  
                                  BuildDateTime  smalldatetime(4)  说明 :empid和employeeid都是员工编码当ftime增加一条数据时在BuildDateTime也增加一条数据
    情况突变: 表  acs_cardevents中的empid是流水号,它对应数据库A中的表e_baserecords中的empno字段
               empno和employeeid都是员工编码