Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Insert bulk failed due to a schema change of the target table

Tags:

ssis

select
   FiscalMonthID = (select FiscalMonthID from CurrentFiscalMonth (nolock)),
   T.OrgKey,
   DataSourceKey = 26,
   OrganizationTypeKey = 2,
   SourceSystemID = MAX(T.MbsId),
   WEGFlag = convert(bit,0),
   D.CreateDT,
   D.CreateBy,
   D.UpdateDT,
   D.UpdateBy

from WorkDB.dbo.TempMbsOrgMap (nolock) as T
join WorkDB.dbo.MBSOrganization_Denorm2 (nolock) as D
      on T.MbsId = D.OrganizationID
--where OrgKey not in (select OrgKey from OrgMap where FiscalMonthID=258 and DataSourceKey=26 and OrganizationTypeKey=2)
group by
   T.OrgKey,
   D.CreateDT,
   D.CreateBy,
   D.UpdateDT,
   D.UpdateBy
like image 613
user604384 Avatar asked Aug 31 '25 22:08

user604384


1 Answers

I don't know whether this person ever got the problem resolved. If anyone else hits this error, the most helpful article I have found so far is: https://learn.microsoft.com/en-us/archive/blogs/sqlserverfaq/executing-bcp-fails-with-sqlstate-37000-nativeerror-4891-error-microsoftodbc-sql-server-driversql-serverinsert-bulk-failed-due-to-a-schema-change-of-the-target-table

The recommendations from the article (it's worth reading the whole thing though) are as follows:

Below is some of the action plan you can try, this helped in my case though.

  1. Drop the Constraints before the BCP run and recreate them after the run

  2. Disable the Auto update stats (To isolate the issue)

  3. Check if any parallel index rebuilds happening.

If still the issue persists after implementing the above change, collect the Profiler trace to capture the activity when bcp is failing to further investigation.

like image 87
gtw Avatar answered Sep 05 '25 02:09

gtw