这是我的存储过程
ALTER PROCEDURE dbo.sync_vmp
AS
BEGIN
SET NOCOUNT ON
merge into FRM_DTA as Target
using FRM_DTA_VMP as Source
on Target.FRM_ID = Source.FRM_ID
when matched then
update set
target.FRM_OWNER = Source.FRM_OWNER,
target.FRM_OWNER_AR = Source.FRM_OWNER_AR,
target.FRM_AREA_ID = Source.FRM_AREA_ID,
target.FRM_AREA = Source.FRM_AREA,
target.FRM_AREA_AR = Source.FRM_AREA_AR,
target.FRM_EMARA_ID = Source.FRM_EMARA_ID,
target.FRM_EMARA = Source.FRM_EMARA,
target.FRM_EMARA_AR = Source.FRM_EMARA_AR,
target.FRM_REGION_ID = Source.FRM_REGION_ID,
target.FRM_REGION = Source.FRM_REGION,
target.FRM_REGION_AR = Source.FRM_REGION_AR,
target.RecievingCentreID = Source.RecievingCentreID,
target.RecievingCentreAr = Source.RecievingCentreAr,
target.RecievingCentre = Source.RecievingCentre,
target.Owner_Address = Source.Owner_Address,
target.Owner_Address_Ar = Source.Owner_Address_Ar,
target.FRM_TELEPHONE = Source.FRM_TELEPHONE,
target.FRM_MOBILE = Source.FRM_MOBILE,
target.Owner_BankName_ID = Source.Owner_BankName_ID,
target.Owner_BankName = Source.Owner_BankName,
target.Owner_BankBranch_ID = Source.Owner_BankBranch_ID,
target.Owner_BankBranch = Source.Owner_BankBranch,
target.BankAccountNo = Source.BankAccountNo,
target.AccountActive = Source.AccountActive,
target.PrefPaymentMethod = Source.PrefPaymentMethod,
target.FRM_CAT = Source.FRM_CAT,
target.farmNumber = Source.farmNumber,
target.FRM_PASSPORT = Source.FRM_PASSPORT,
target.FRM_Approve = Source.FRM_Approve,
target.FRM_AUDIT_STATUS = Source.FRM_AUDIT_STATUS,
target.FRM_AUDIT_REASON = Source.FRM_AUDIT_REASON,
target.FRM_WATER_SAL = Source.FRM_WATER_SAL,
target.FRM_SOL_SAL = Source.FRM_SOL_SAL,
target.syn_status = Source.syn_status,
target.FRM_status = Source.FRM_status,
target.Call_status = Source.Call_status,
target.ALZAKA_CH = Source.ALZAKA_CH
when not matched then
insert(FRM_ID,FRM_OWNER,FRM_OWNER_AR,FRM_AREA_ID,FRM_AREA,FRM_AREA_AR,FRM_EMARA_ID,FRM_EMARA,FRM_EMARA_AR,FRM_REGION_ID,FRM_REGION,FRM_REGION_AR,RecievingCentreID,RecievingCentreAr,RecievingCentre,Owner_Address,Owner_Address_Ar,FRM_TELEPHONE,FRM_MOBILE,Owner_BankName_ID,Owner_BankName,Owner_BankBranch_ID,Owner_BankBranch,BankAccountNo,AccountActive,PrefPaymentMethod,FRM_CAT,farmNumber,FRM_PASSPORT,FRM_Approve,FRM_AUDIT_STATUS,FRM_AUDIT_REASON,FRM_WATER_SAL,FRM_SOL_SAL,syn_status,FRM_status,Call_status,ALZAKA_CH)
values (Source.FRM_ID,Source.FRM_OWNER, Source.FRM_OWNER_AR,Source.FRM_AREA_ID,Source.FRM_AREA,Source.FRM_AREA_AR,Source.FRM_EMARA_ID,Source.FRM_EMARA,Source.FRM_EMARA_AR,Source.FRM_REGION_ID,Source.FRM_REGION,Source.FRM_REGION_AR,Source.RecievingCentreID,Source.RecievingCentreAr,Source.RecievingCentre,Source.Owner_Address,Source.Owner_Address_Ar,Source.FRM_TELEPHONE,Source.FRM_MOBILE,Source.Owner_BankName_ID,Source.Owner_BankName,Source.Owner_BankBranch_ID,Source.Owner_BankBranch,Source.BankAccountNo,Source.AccountActive,Source.PrefPaymentMethod,Source.FRM_CAT,Source.farmNumber,Source.FRM_PASSPORT,Source.FRM_Approve,Source.FRM_AUDIT_STATUS,Source.FRM_AUDIT_REASON,Source.FRM_WATER_SAL,Source.FRM_SOL_SAL,Source.syn_status,Source.FRM_status,Source.Call_status,Source.ALZAKA_CH);
END
这是一个例外:
存储过程非常简单,只需将 upsert 数据从一个表移植到另一个表。
你能告诉我为什么我得到那个例外吗?
非常感谢答案 0 :(得分:2)
在;
之后添加SET NOCOUNT ON
,它会起作用。