数据库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 vachar(20)
ftime smalldatetime(4) 数据库B
表 GM_KQ_TimeRecorderData employeeid vachar(20)
BuildDateTime smalldatetime(4)说明 :empid和employeeid都是员工编码,当ftime增加一条数据时在BuildDateTime也增加一条数据
解决方案 »
- 这个sql语句怎么写?从章节1随机选取30道题,从章节2随机选取20道题目
- 关于SQL SERVER的初级问题
- sql2005,设计表的时候,id不从1开始,从5开始的??10分
- 为什么删除不了
- ???安装时提示:无法读取指定文件,极有可能是由于网络连接不正常所致,请更正该问题然后重新启动安装程序。
- 高手请进:新建数据表问题
- 在将 varchar 值 '[%0]' 转换成数据类型 int 时失败。
- 求一个SQL语句?
- 有没有办法屏蔽存储过程的错误提示信息内容!
- 该伙伴事务管理器已经禁止了它对远程/网络事务的支持。
- T-SQL语法
- powerdesigner反向工程中如何得到sqlserver的字段描述
for insert
as
insert into GM_KQ_TimeRecorderData select * from inserted
@ftime smalldatetime(4)select @EmpID=empid,
@ftime=ftime
from Insertedinsert into GM_KQ_TimeRecorderData(employeeid,BuildDateTime)
values(@EmpID,@ftime)
@ftime smalldatetime(4) select @EmpID=empid,
@ftime=ftime from Inserted insert into GM_KQ_TimeRecorderData(employeeid,BuildDateTime)
values(@EmpID,@ftime)
提示我GM_KQ_TimeRecorderData这个无效
values(@EmpID,@ftime)
不在同一个库里要加上数据库的全称
as
insert into 数据库B.dbo.GM_KQ_TimeRecorderData(employeeid,BuildDateTime) select * from inserted
表 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
改成这样
insert into 数据库B.dbo.GM_KQ_TimeRecorderData(employeeid,BuildDateTime)
select (right('000000'+empid,6),ftime ) from inserted
表 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都是员工编码