When using SSIS to load data from a source table, we have a OLE DB Destination that uses a Data Access Mode of “Table or View – fast load” (which uses a BULK INSERT to do the work). When we try to execute the task, we get a very strange error message:
Error: 4804, Severity: 17, State: 1 While reading current row from
host, a premature end-of-message was encountered–an incoming data
stream was interrupted when the server expected to see more data. The
host program may have terminated. Ensure that you are using a
supported client application programming interface (API).
The error seems to indicate that there is some kind of corruption in the incoming data, but we have already scrubbed the source data and everything looks ok. If we change the Data Access Mode to “Table or view” (which uses a cursor to do the INSERTs), every row is added without any error.
Table definition:
CREATE TABLE [dbo].[CUST](
[CUST_FIRST_NM] [varchar](50) NOT NULL,
[CUST_MIDL_INIT] [char](1) NULL,
[CUST_LAST_NM] [varchar](50) NOT NULL,
[CUST_EMAIL_ADDR] [varchar](100) NULL,
[CUST_TELE_PHONE_NBR] [int] NULL,
[CUST_TELE_CNTRY_CD] [smallint] NULL,
[CUST_TELE_AREA_CD] [smallint] NULL,
[LAST_UPD_DTTM] [datetime] NOT NULL,
[CUST_ID] [bigint] IDENTITY(1,1) NOT NULL,
[CUST_CD] AS ('PUB'+right(CONVERT([varchar](max),CONVERT([varbinary],[CUST_ID],0),(1)),(7))),
CONSTRAINT [XPKCUST] PRIMARY KEY CLUSTERED
(
[CUST_ID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
Any idea what might be causing this error?
As it turns out, I was able to answer my own question, so I am posting it here on StackOverflow to benefit the community. 🙂
The problem was the computed column CUST_CD. After a lot of researching, it seems that the BULK INSERT does not like complex computed types (see https://stackoverflow.com/questions/4031909/using-sql-server-spatial-types-in-ssis-data-load). The solution is to removed the computed column and just make it a varchar(20) NULL. Then I created a new Execute SQL Task that updates any NULL rows with the computed value.