急急,请求求小弟,一个MSSQL数据更新问题!

时间:2022-11-26 20:43:40
单位一个餐饮系统,是MSSQL数据库的,因为近期更新了操作系统,重新部署餐饮系统,一切都很顺利,但是就在员工补领新饭卡的时候,操作员对其员工的工号进行更改为对应的IC卡卡号时,操作时系统有提示更改成功,但是返回一看工号却没有变化,我问了那个开发公司的,但是不提供技术支持,需要付费,而且非常高昂,他扯蛋了。他说是什么触发器问题,应该是指MSSQL的触发器吧,我就搞不懂了。

如果是触发器有问题,那请问该怎么弄?

如果触发器这个问题不能解决,请问有什么sql语句可以,实现以上功能
更改工号,涉及到员工信息表、餐饮报销餐表、餐饮就餐表等表,如何实现多个表同时更新员工工号字段的数据呢?

请大侠帮帮小弟。感激不尽!

9 个解决方案

#1


还是给钱找开发公司整一下吧

#2


这个不好说,要看数据库和外部程序怎么设计的了。
如果自己有权限更改,无论怎么弄都行。

#3




引用 2 楼  的回复:
这个不好说,要看数据库和外部程序怎么设计的了。
如果自己有权限更改,无论怎么弄都行。




我想手动用sql脚本来更改,不用他们的程序,应该也行吧

#4


能帮我编一个脚本吗,就算不能从程序端更改,我也得要从服务端上更改

#5


没有源代码吗?如果有自己调试一下呗

#6


引用 5 楼  的回复:
没有源代码吗?如果有自己调试一下呗


你好,研究了一个晚上终于找到触发器,发现其触发器是禁用状态的,于是我启用了,但是还是没有解决问题,我看了触发器的脚本,应该是这个没错的。但还是失效,到底是怎么回事呢。

#7


USE [EMHR2009]
GO
/****** Object:  Trigger [dbo].[UpdateEmpNo]    Script Date: 07/04/2012 09:26:42 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
  ALTER TRIGGER [dbo].[UpdateEmpNo] ON [dbo].[Employee] 
  FOR UPDATE 
  AS 
  declare @empno varchar(20), @NewEmpNo varchar(20) 
  select @empno=(select top 1 empno from deleted) 
  select @NewEmpNo=(select top 1 EmpNo from Inserted) 
  if @empno is not null 
  if Update(empno) 
  begin 
  insert into EmpNoChangeLog (OldEmpNo, NewEmpNo, ChangeDate) values (@empno, @NewEmpNo, getdate()) 
 update AboutMoneyMaster set EmpNo=inserted.EmpNo from AboutMoneyMaster,inserted,deleted where AboutMoneyMaster.EmpNo=deleted.EmpNo 
 update AddOverTimeEmployee set EmpNo=inserted.EmpNo from AddOverTimeEmployee,inserted,deleted where AddOverTimeEmployee.EmpNo=deleted.EmpNo 
 update AddressManageDetail set EmpNo=inserted.EmpNo from AddressManageDetail,inserted,deleted where AddressManageDetail.EmpNo=deleted.EmpNo 
 update AddWorkList set EmpNo=inserted.EmpNo from AddWorkList,inserted,deleted where AddWorkList.EmpNo=deleted.EmpNo 
 update AddWorkTimeReq set EmpNo=inserted.EmpNo from AddWorkTimeReq,inserted,deleted where AddWorkTimeReq.EmpNo=deleted.EmpNo 
 update AddWorkTimeReq_B set EmpNo=inserted.EmpNo from AddWorkTimeReq_B,inserted,deleted where AddWorkTimeReq_B.EmpNo=deleted.EmpNo 
 update Assess2 set EmpNo=inserted.EmpNo from Assess2,inserted,deleted where Assess2.EmpNo=deleted.EmpNo 
 update AssessMonthData set EmpNo=inserted.EmpNo from AssessMonthData,inserted,deleted where AssessMonthData.EmpNo=deleted.EmpNo 
 update ASTList set EmpNo=inserted.EmpNo from ASTList,inserted,deleted where ASTList.EmpNo=deleted.EmpNo 
 update B_AddDetail set EmpNo=inserted.EmpNo from B_AddDetail,inserted,deleted where B_AddDetail.EmpNo=deleted.EmpNo 
 update Backup_CardData set EmpNo=inserted.EmpNo from Backup_CardData,inserted,deleted where Backup_CardData.EmpNo=deleted.EmpNo 
 update Backup_CardDataRecord set EmpNo=inserted.EmpNo from Backup_CardDataRecord,inserted,deleted where Backup_CardDataRecord.EmpNo=deleted.EmpNo 
 update Backup_ChangePD set EmpNo=inserted.EmpNo from Backup_ChangePD,inserted,deleted where Backup_ChangePD.EmpNo=deleted.EmpNo 
 update Backup_EmployeeChangePay set EmpNo=inserted.EmpNo from Backup_EmployeeChangePay,inserted,deleted where Backup_EmployeeChangePay.EmpNo=deleted.EmpNo 
 update Backup_EmployeeDayCardData set EmpNo=inserted.EmpNo from Backup_EmployeeDayCardData,inserted,deleted where Backup_EmployeeDayCardData.EmpNo=deleted.EmpNo 

#8


 update Backup_EmployeeJC set EmpNo=inserted.EmpNo from Backup_EmployeeJC,inserted,deleted where Backup_EmployeeJC.EmpNo=deleted.EmpNo 
 update Backup_EmployeeMonthCount set EmpNo=inserted.EmpNo from Backup_EmployeeMonthCount,inserted,deleted where Backup_EmployeeMonthCount.EmpNo=deleted.EmpNo 
 update Backup_EmployeeMonthPay set EmpNo=inserted.EmpNo from Backup_EmployeeMonthPay,inserted,deleted where Backup_EmployeeMonthPay.EmpNo=deleted.EmpNo 
 update Backup_EmployeeRestDay set EmpNo=inserted.EmpNo from Backup_EmployeeRestDay,inserted,deleted where Backup_EmployeeRestDay.EmpNo=deleted.EmpNo 
 update Backup_EmployeeWorksList set EmpNo=inserted.EmpNo from Backup_EmployeeWorksList,inserted,deleted where Backup_EmployeeWorksList.EmpNo=deleted.EmpNo 
 update Backup_MonthCountJJ set EmpNo=inserted.EmpNo from Backup_MonthCountJJ,inserted,deleted where Backup_MonthCountJJ.EmpNo=deleted.EmpNo 
 update Backup_PleaseIll_Detail set EmpNo=inserted.EmpNo from Backup_PleaseIll_Detail,inserted,deleted where Backup_PleaseIll_Detail.EmpNo=deleted.EmpNo 
 update Backup_PleaseIll_Master set EmpNo=inserted.EmpNo from Backup_PleaseIll_Master,inserted,deleted where Backup_PleaseIll_Master.EmpNo=deleted.EmpNo 
 update Backup_StopWork set EmpNo=inserted.EmpNo from Backup_StopWork,inserted,deleted where Backup_StopWork.EmpNo=deleted.EmpNo 
 update BalconyChangeRecord set EmpNo=inserted.EmpNo from BalconyChangeRecord,inserted,deleted where BalconyChangeRecord.EmpNo=deleted.EmpNo 
 update bankpay set EmpNo=inserted.EmpNo from bankpay,inserted,deleted where bankpay.EmpNo=deleted.EmpNo 
 update BankReport set EmpNo=inserted.EmpNo from BankReport,inserted,deleted where BankReport.EmpNo=deleted.EmpNo 
 update Barcodeinput set EmpNo=inserted.EmpNo from Barcodeinput,inserted,deleted where Barcodeinput.EmpNo=deleted.EmpNo 
 update BatchRest set EmpNo=inserted.EmpNo from BatchRest,inserted,deleted where BatchRest.EmpNo=deleted.EmpNo 
 update Belongings set EmpNo=inserted.EmpNo from Belongings,inserted,deleted where Belongings.EmpNo=deleted.EmpNo 
 update BRW set EmpNo=inserted.EmpNo from BRW,inserted,deleted where BRW.EmpNo=deleted.EmpNo 
 update CardData set EmpNo=inserted.EmpNo from CardData,inserted,deleted where CardData.EmpNo=deleted.EmpNo 
 update CardData_B set EmpNo=inserted.EmpNo from CardData_B,inserted,deleted where CardData_B.EmpNo=deleted.EmpNo 
 update CardData_RealTime set EmpNo=inserted.EmpNo from CardData_RealTime,inserted,deleted where CardData_RealTime.EmpNo=deleted.EmpNo 
 update CardDataRecord set EmpNo=inserted.EmpNo from CardDataRecord,inserted,deleted where CardDataRecord.EmpNo=deleted.EmpNo 
 update CardDataRecord_B set EmpNo=inserted.EmpNo from CardDataRecord_B,inserted,deleted where CardDataRecord_B.EmpNo=deleted.EmpNo 
 update CardNameList set EmpNo=inserted.EmpNo from CardNameList,inserted,deleted where CardNameList.EmpNo=deleted.EmpNo 
 update CardOperation set EmpNo=inserted.EmpNo from CardOperation,inserted,deleted where CardOperation.EmpNo=deleted.EmpNo 
 update CardOperation_Temp set EmpNo=inserted.EmpNo from CardOperation_Temp,inserted,deleted where CardOperation_Temp.EmpNo=deleted.EmpNo 
 update CardOperationTemp set EmpNo=inserted.EmpNo from CardOperationTemp,inserted,deleted where CardOperationTemp.EmpNo=deleted.EmpNo 
 update CardToMachine set EmpNo=inserted.EmpNo from CardToMachine,inserted,deleted where CardToMachine.EmpNo=deleted.EmpNo 
 update CardToMachine_Cy set EmpNo=inserted.EmpNo from CardToMachine_Cy,inserted,deleted where CardToMachine_Cy.EmpNo=deleted.EmpNo 
 update CardToMachine_Mj set EmpNo=inserted.EmpNo from CardToMachine_Mj,inserted,deleted where CardToMachine_Mj.EmpNo=deleted.EmpNo 
 update CelerityWorksList set EmpNo=inserted.EmpNo from CelerityWorksList,inserted,deleted where CelerityWorksList.EmpNo=deleted.EmpNo 
 update ChangePD set EmpNo=inserted.EmpNo from ChangePD,inserted,deleted where ChangePD.EmpNo=deleted.EmpNo 
 update ChangePD2 set EmpNo=inserted.EmpNo from ChangePD2,inserted,deleted where ChangePD2.EmpNo=deleted.EmpNo 
 update CheckGroupDetail set EmpNo=inserted.EmpNo from CheckGroupDetail,inserted,deleted where CheckGroupDetail.EmpNo=deleted.EmpNo 
 update CheckGroupDetail_B set EmpNo=inserted.EmpNo from CheckGroupDetail_B,inserted,deleted where CheckGroupDetail_B.EmpNo=deleted.EmpNo 
 update ClockSetInfo set EmpNo=inserted.EmpNo from ClockSetInfo,inserted,deleted where ClockSetInfo.EmpNo=deleted.EmpNo 
 update ContinueWorkDay set EmpNo=inserted.EmpNo from ContinueWorkDay,inserted,deleted where ContinueWorkDay.EmpNo=deleted.EmpNo 
 update CountEmployeeDayCardData set EmpNo=inserted.EmpNo from CountEmployeeDayCardData,inserted,deleted where CountEmployeeDayCardData.EmpNo=deleted.EmpNo 
 update CountTask set EmpNo=inserted.EmpNo from CountTask,inserted,deleted where CountTask.EmpNo=deleted.EmpNo 
 update Cupboard set EmpNo=inserted.EmpNo from Cupboard,inserted,deleted where Cupboard.EmpNo=deleted.EmpNo 
 update Custom set EmpNo=inserted.EmpNo from Custom,inserted,deleted where Custom.EmpNo=deleted.EmpNo 

#9


若是有预算,乐意远程试试。虽不能保证一定解决

#1


还是给钱找开发公司整一下吧

#2


这个不好说,要看数据库和外部程序怎么设计的了。
如果自己有权限更改,无论怎么弄都行。

#3




引用 2 楼  的回复:
这个不好说,要看数据库和外部程序怎么设计的了。
如果自己有权限更改,无论怎么弄都行。




我想手动用sql脚本来更改,不用他们的程序,应该也行吧

#4


能帮我编一个脚本吗,就算不能从程序端更改,我也得要从服务端上更改

#5


没有源代码吗?如果有自己调试一下呗

#6


引用 5 楼  的回复:
没有源代码吗?如果有自己调试一下呗


你好,研究了一个晚上终于找到触发器,发现其触发器是禁用状态的,于是我启用了,但是还是没有解决问题,我看了触发器的脚本,应该是这个没错的。但还是失效,到底是怎么回事呢。

#7


USE [EMHR2009]
GO
/****** Object:  Trigger [dbo].[UpdateEmpNo]    Script Date: 07/04/2012 09:26:42 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
  ALTER TRIGGER [dbo].[UpdateEmpNo] ON [dbo].[Employee] 
  FOR UPDATE 
  AS 
  declare @empno varchar(20), @NewEmpNo varchar(20) 
  select @empno=(select top 1 empno from deleted) 
  select @NewEmpNo=(select top 1 EmpNo from Inserted) 
  if @empno is not null 
  if Update(empno) 
  begin 
  insert into EmpNoChangeLog (OldEmpNo, NewEmpNo, ChangeDate) values (@empno, @NewEmpNo, getdate()) 
 update AboutMoneyMaster set EmpNo=inserted.EmpNo from AboutMoneyMaster,inserted,deleted where AboutMoneyMaster.EmpNo=deleted.EmpNo 
 update AddOverTimeEmployee set EmpNo=inserted.EmpNo from AddOverTimeEmployee,inserted,deleted where AddOverTimeEmployee.EmpNo=deleted.EmpNo 
 update AddressManageDetail set EmpNo=inserted.EmpNo from AddressManageDetail,inserted,deleted where AddressManageDetail.EmpNo=deleted.EmpNo 
 update AddWorkList set EmpNo=inserted.EmpNo from AddWorkList,inserted,deleted where AddWorkList.EmpNo=deleted.EmpNo 
 update AddWorkTimeReq set EmpNo=inserted.EmpNo from AddWorkTimeReq,inserted,deleted where AddWorkTimeReq.EmpNo=deleted.EmpNo 
 update AddWorkTimeReq_B set EmpNo=inserted.EmpNo from AddWorkTimeReq_B,inserted,deleted where AddWorkTimeReq_B.EmpNo=deleted.EmpNo 
 update Assess2 set EmpNo=inserted.EmpNo from Assess2,inserted,deleted where Assess2.EmpNo=deleted.EmpNo 
 update AssessMonthData set EmpNo=inserted.EmpNo from AssessMonthData,inserted,deleted where AssessMonthData.EmpNo=deleted.EmpNo 
 update ASTList set EmpNo=inserted.EmpNo from ASTList,inserted,deleted where ASTList.EmpNo=deleted.EmpNo 
 update B_AddDetail set EmpNo=inserted.EmpNo from B_AddDetail,inserted,deleted where B_AddDetail.EmpNo=deleted.EmpNo 
 update Backup_CardData set EmpNo=inserted.EmpNo from Backup_CardData,inserted,deleted where Backup_CardData.EmpNo=deleted.EmpNo 
 update Backup_CardDataRecord set EmpNo=inserted.EmpNo from Backup_CardDataRecord,inserted,deleted where Backup_CardDataRecord.EmpNo=deleted.EmpNo 
 update Backup_ChangePD set EmpNo=inserted.EmpNo from Backup_ChangePD,inserted,deleted where Backup_ChangePD.EmpNo=deleted.EmpNo 
 update Backup_EmployeeChangePay set EmpNo=inserted.EmpNo from Backup_EmployeeChangePay,inserted,deleted where Backup_EmployeeChangePay.EmpNo=deleted.EmpNo 
 update Backup_EmployeeDayCardData set EmpNo=inserted.EmpNo from Backup_EmployeeDayCardData,inserted,deleted where Backup_EmployeeDayCardData.EmpNo=deleted.EmpNo 

#8


 update Backup_EmployeeJC set EmpNo=inserted.EmpNo from Backup_EmployeeJC,inserted,deleted where Backup_EmployeeJC.EmpNo=deleted.EmpNo 
 update Backup_EmployeeMonthCount set EmpNo=inserted.EmpNo from Backup_EmployeeMonthCount,inserted,deleted where Backup_EmployeeMonthCount.EmpNo=deleted.EmpNo 
 update Backup_EmployeeMonthPay set EmpNo=inserted.EmpNo from Backup_EmployeeMonthPay,inserted,deleted where Backup_EmployeeMonthPay.EmpNo=deleted.EmpNo 
 update Backup_EmployeeRestDay set EmpNo=inserted.EmpNo from Backup_EmployeeRestDay,inserted,deleted where Backup_EmployeeRestDay.EmpNo=deleted.EmpNo 
 update Backup_EmployeeWorksList set EmpNo=inserted.EmpNo from Backup_EmployeeWorksList,inserted,deleted where Backup_EmployeeWorksList.EmpNo=deleted.EmpNo 
 update Backup_MonthCountJJ set EmpNo=inserted.EmpNo from Backup_MonthCountJJ,inserted,deleted where Backup_MonthCountJJ.EmpNo=deleted.EmpNo 
 update Backup_PleaseIll_Detail set EmpNo=inserted.EmpNo from Backup_PleaseIll_Detail,inserted,deleted where Backup_PleaseIll_Detail.EmpNo=deleted.EmpNo 
 update Backup_PleaseIll_Master set EmpNo=inserted.EmpNo from Backup_PleaseIll_Master,inserted,deleted where Backup_PleaseIll_Master.EmpNo=deleted.EmpNo 
 update Backup_StopWork set EmpNo=inserted.EmpNo from Backup_StopWork,inserted,deleted where Backup_StopWork.EmpNo=deleted.EmpNo 
 update BalconyChangeRecord set EmpNo=inserted.EmpNo from BalconyChangeRecord,inserted,deleted where BalconyChangeRecord.EmpNo=deleted.EmpNo 
 update bankpay set EmpNo=inserted.EmpNo from bankpay,inserted,deleted where bankpay.EmpNo=deleted.EmpNo 
 update BankReport set EmpNo=inserted.EmpNo from BankReport,inserted,deleted where BankReport.EmpNo=deleted.EmpNo 
 update Barcodeinput set EmpNo=inserted.EmpNo from Barcodeinput,inserted,deleted where Barcodeinput.EmpNo=deleted.EmpNo 
 update BatchRest set EmpNo=inserted.EmpNo from BatchRest,inserted,deleted where BatchRest.EmpNo=deleted.EmpNo 
 update Belongings set EmpNo=inserted.EmpNo from Belongings,inserted,deleted where Belongings.EmpNo=deleted.EmpNo 
 update BRW set EmpNo=inserted.EmpNo from BRW,inserted,deleted where BRW.EmpNo=deleted.EmpNo 
 update CardData set EmpNo=inserted.EmpNo from CardData,inserted,deleted where CardData.EmpNo=deleted.EmpNo 
 update CardData_B set EmpNo=inserted.EmpNo from CardData_B,inserted,deleted where CardData_B.EmpNo=deleted.EmpNo 
 update CardData_RealTime set EmpNo=inserted.EmpNo from CardData_RealTime,inserted,deleted where CardData_RealTime.EmpNo=deleted.EmpNo 
 update CardDataRecord set EmpNo=inserted.EmpNo from CardDataRecord,inserted,deleted where CardDataRecord.EmpNo=deleted.EmpNo 
 update CardDataRecord_B set EmpNo=inserted.EmpNo from CardDataRecord_B,inserted,deleted where CardDataRecord_B.EmpNo=deleted.EmpNo 
 update CardNameList set EmpNo=inserted.EmpNo from CardNameList,inserted,deleted where CardNameList.EmpNo=deleted.EmpNo 
 update CardOperation set EmpNo=inserted.EmpNo from CardOperation,inserted,deleted where CardOperation.EmpNo=deleted.EmpNo 
 update CardOperation_Temp set EmpNo=inserted.EmpNo from CardOperation_Temp,inserted,deleted where CardOperation_Temp.EmpNo=deleted.EmpNo 
 update CardOperationTemp set EmpNo=inserted.EmpNo from CardOperationTemp,inserted,deleted where CardOperationTemp.EmpNo=deleted.EmpNo 
 update CardToMachine set EmpNo=inserted.EmpNo from CardToMachine,inserted,deleted where CardToMachine.EmpNo=deleted.EmpNo 
 update CardToMachine_Cy set EmpNo=inserted.EmpNo from CardToMachine_Cy,inserted,deleted where CardToMachine_Cy.EmpNo=deleted.EmpNo 
 update CardToMachine_Mj set EmpNo=inserted.EmpNo from CardToMachine_Mj,inserted,deleted where CardToMachine_Mj.EmpNo=deleted.EmpNo 
 update CelerityWorksList set EmpNo=inserted.EmpNo from CelerityWorksList,inserted,deleted where CelerityWorksList.EmpNo=deleted.EmpNo 
 update ChangePD set EmpNo=inserted.EmpNo from ChangePD,inserted,deleted where ChangePD.EmpNo=deleted.EmpNo 
 update ChangePD2 set EmpNo=inserted.EmpNo from ChangePD2,inserted,deleted where ChangePD2.EmpNo=deleted.EmpNo 
 update CheckGroupDetail set EmpNo=inserted.EmpNo from CheckGroupDetail,inserted,deleted where CheckGroupDetail.EmpNo=deleted.EmpNo 
 update CheckGroupDetail_B set EmpNo=inserted.EmpNo from CheckGroupDetail_B,inserted,deleted where CheckGroupDetail_B.EmpNo=deleted.EmpNo 
 update ClockSetInfo set EmpNo=inserted.EmpNo from ClockSetInfo,inserted,deleted where ClockSetInfo.EmpNo=deleted.EmpNo 
 update ContinueWorkDay set EmpNo=inserted.EmpNo from ContinueWorkDay,inserted,deleted where ContinueWorkDay.EmpNo=deleted.EmpNo 
 update CountEmployeeDayCardData set EmpNo=inserted.EmpNo from CountEmployeeDayCardData,inserted,deleted where CountEmployeeDayCardData.EmpNo=deleted.EmpNo 
 update CountTask set EmpNo=inserted.EmpNo from CountTask,inserted,deleted where CountTask.EmpNo=deleted.EmpNo 
 update Cupboard set EmpNo=inserted.EmpNo from Cupboard,inserted,deleted where Cupboard.EmpNo=deleted.EmpNo 
 update Custom set EmpNo=inserted.EmpNo from Custom,inserted,deleted where Custom.EmpNo=deleted.EmpNo 

#9


若是有预算,乐意远程试试。虽不能保证一定解决