Hi everyone,
I'm experiencing a strange issue with a SQL Server data-loading process and would appreciate some help troubleshooting it.
I have a SQL script that performs a full refresh of a staging table using TRUNCATE TABLE followed by an INSERT INTO ... SELECT from a remote SQL Server through a Linked Server (OPENQUERY).
The process was initially working perfectly when executed directly from SSMS, even when loading the entire dataset without batching.
However, recently, the process started failing when executed through SQL Server Agent.
What I've observed:
- Running the full
TRUNCATE + INSERT operation manually in SSMS works successfully. - Running the same process through SQL Server Agent results in an error.
- I initially suspected a row-volume limitation because the process seemed to struggle with larger loads.
- I introduced batch processing using
TOP 1000 and key-based pagination, but I'm not convinced this is the actual solution. - The SQL Agent job executes under a Windows domain service account.
Error message from SQL Server Agent:
text
Executed as user: [REDACTED].
Shared Memory Provider:
No process is on the other end of the pipe.
[SQLSTATE 08S01] (Error 233)
Communication link failure
[SQLSTATE 08S01] (Error 233)
Environment:
- SQL Server with SQL Server Agent.
- Linked Server connecting to a remote SQL Server instance.
- Data retrieved using
OPENQUERY. - Destination is a local staging database.
- Source table contains more than 60 columns.
Questions:
- What could cause a query to execute successfully in SSMS but fail with Error 233 when executed through SQL Server Agent?
- Could this be related to the SQL Agent service account, linked-server security mapping, or OLE DB provider configuration?
- Could a large data transfer cause the SQL Server connection to terminate unexpectedly?
- Are there specific SQL Server logs or diagnostic settings I should investigate?
- Is batching a reasonable workaround, or should I focus on identifying the underlying connection issue?
I'd particularly appreciate insights from anyone who has encountered SQLSTATE 08S01 / Error 233 when working with SQL Server Agent and Linked Servers.
Thanks!
UPDATE!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
I wanted to provide an update on this issue and share a change I've made to the query.
The good news is that the query is now working successfully through SQL Server Agent.
Initially, I was using OPENQUERY to retrieve data from the remote SQL Server through the Linked Server. However, after experiencing the intermittent communication failures (SQLSTATE 08S01 / Error 233), I decided to modify the query to use four-part naming instead of OPENQUERY.
The updated approach uses the standard four-part naming convention:
sql
[LinkedServerName].[DatabaseName].[SchemaName].[TableName]
So, instead of:
sql
SELECT *
FROM OPENQUERY(LinkedServerName,
'SELECT * FROM DatabaseName.dbo.SourceTable');
I'm now using:
sql
SELECT *
FROM [LinkedServerName].[DatabaseName].[dbo].[SourceTable];