Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6195291
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T03:26:37+00:00 2026-05-24T03:26:37+00:00

All SQL Servers are SQL Server 2008…. I have a table that is replicated

  • 0

All SQL Servers are SQL Server 2008….

I have a table that is replicated to a data center. I have written an AFTER INSERT & AFTER UPDATE trigger on this table. When data is replicated to the table, the subscription reports errors

column name or number of supplied values does not match table
definition

I can manually insert records & the trigger works fine though when replication attempts to insert records, I get the message above. Below are my triggers..

I am sure the error emanates from the trigger, but I am at a loss why…

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 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T03:26:38+00:00Added an answer on May 24, 2026 at 3:26 am

    Your problem is here

    INSERT INTO tblReceivingHeaderStatus_1
    
    select ...
    

    Don’t do that. Instead specify the columns you’re inserting into e.g.

    INSERT INTO tblReceivingHeaderStatus_1
    (  fieldA, 
       FieldB
       ...
    )
    SELECT ...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

servers all sql server 2008, and win xp i have the following task create
I have a field in my SQL Server 2008 table that is auto number
I've got some code that runs all lovely on SQL Server 2008, however I'm
I am using SQL Server 2008 and I need to select all data from
Our database server is a SQL 2008 server. My colleagues all have XP service
In SQL Server 2000, you have the All Tasks... - Export Data option. Where
I have tried to make use of linked servers in SQL Server 2008 by
I have 3 home PCs that have 2008 SQL Server Express instances installed on
SQL Server 2008 Profiler always profiles all databases. I want to restrict profiling or
I am converting all my SQL Server queries to MySQL and my queries that

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.