すべてのSQL ServerはSQL Server 2008です。レプリケーションとトリガー
データセンターにレプリケートされたテーブルがあります。このテーブルでAFTER UPDATEトリガー& AFTER UPDATEトリガーを書いています。データを表に複製されると、サブスクリプションがエラーを報告された値の
列名または番号がテーブルに 定義
と一致していない私は、手動でトリガをするとき、複製けれども正常に動作したレコード&を挿入することができますレコードを挿入しようとすると、上記のメッセージが表示されます。以下は私のトリガーは..です
私はエラーがトリガーから発する確信しているが、私はなぜ途方に暮れています...
AHIA、
LarryR ...
-- =============================================
-- Description: Updates tblReceivingHeaderStatus_1
-- =============================================
create TRIGGER [dbo].[UPD_tblReceivingHeaderStatus_1]
ON [dbo].[tblReceivingHeader]
AFTER UPDATE
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
declare @SeqNum numeric ,@Location numeric
select @SeqNum = i.SeqNum, @Location = i.Location
from tblReceivingHeaderStatus_1 D
left join inserted i on D.Location = i.Location and D.SeqNum = i.SeqNum
UPDATE tblReceivingHeaderStatus_1
SET AdjTax = inserted.AdjTax,
AdjDeliveryFee = inserted.AdjDeliveryFee,
AdjDiscount = inserted.AdjDiscount,
AdjInvoiceTotal = inserted.AdjInvoiceTotal,
AdjItemCount= inserted.AdjItemCount,
AdjInvoiceInfo = inserted.AdjInvoiceInfo,
InvoiceAdjReason = ISNULL(inserted.InvoiceAdjReason,''),
PaidFlag = inserted.PaidFlag,
StartDate = inserted.StartDate,
CheckComments = inserted.CheckComments,
POeMailSent =
case inserted.CheckComments
when '.' then 'P'
else ''
end,
PONumber = inserted.PONumber,
[Status] = inserted.[Status],
MiscFlag2 = 'T'
FROM
inserted
WHERE
inserted.seqnum = tblReceivingHeaderStatus_1.seqnum AND
inserted.location = tblReceivingHeaderStatus_1.location ;
--this assigns all inventory PO receivers to someone in pricing to approve
update tblReceivingHeaderStatus_1
set NextApprover = 1
from tblReceivingHeaderStatus_1
left join apvendp on vmvend = vendornum
where
recdevice = 'P' and
status = '1' and
NextApprover <> 1 and
vminex = 'I' ;
--update tblReceivingHeader to show the record has been
--updated in tblReceivingHeaderStatus_1
update tblReceivingHeader
set MovedToAs400 = 'Y'
where tblReceivingHeader.SeqNum = @SeqNum
and tblReceivingHeader.Location = @Location ;
END
-- ==========================================================
-- Description: Insert records into tblReceivingHeaderStatus_1
-- ==========================================================
create TRIGGER [dbo].[INS_INTO_tblReceivingHeaderStatus_1]
ON [dbo].[tblReceivingHeader]
AFTER INSERT
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
declare @SeqNum numeric ,@Location numeric
--get the seqnum & location from the inserted record
select @SeqNum = i.SeqNum, @Location = i.Location
from tblReceivingHeaderStatus_1 D
left join inserted i on D.Location = i.Location and D.SeqNum = i.SeqNum;
INSERT INTO tblReceivingHeaderStatus_1
select
SeqNum,VendorNum,InvoiceNum,InvoiceTotal,ItemCount,
InvoiceDate,Status,Location,AdjTax,AdjDeliveryFee,AdjDiscount,
AdjInvoiceTotal,AdjItemCount,isnull(AdjInvoiceInfo,''),Tax,
DeliveryFee,Discount,ApprovedTime,ApprovedDate,ApprovedBy,
InvoiceAdjReason,'N', GETDATE(),PaidFlag,StartDate,
case CheckComments
when '.' then 'P'
else ''
end,
' ', 0, PONumber, recDevice, '', '', '', 'T', '', '', '', '', 0, 0, 0, '',
msrepl_tran_version
FROM inserted;
-- update tblReceivingHeader to show the record has been
-- inserted into tblReceivingHeaderStatus_1
update tblReceivingHeader
set MovedToAs400 = 'Y'
where
tblReceivingHeader.SeqNum = @SeqNum
and tblReceivingHeader.Location = @Location;
END
1は、はい、絶対に...あなたがいないレプリケーション用としてマークされていますtblReceivingHeaderStatus_1のID列を持っている賭けますテーブルが突然列のリストを変更するとき....) –
Conrad ...私はそれについて考えましたが、データを手作業で挿入すると、テーブルグリッドまたは挿入ステートメントにコピー&ペーストします。なぜ??? – larryr