This is question is related to answer of Can Sql Server BULK INSERT read from a named pipe/fifo?
@Grimace_of_Despair provided a solution using C#. See the GitHub project for more details.
Create a Named Pipe with
server name = .
public NamedPipe(string name, string server, string dataValue) { _dataValue = dataValue; Name = name; Server = server; Stream = new NamedPipeServerStream(name, PipeDirection.Out, 2, PipeTransmissionMode.Byte, PipeOptions.Asynchronous); Stream.BeginWaitForConnection(OnConnection, this); }
Bulk Insert using Named Pipe
var insertCommand = DbConnection.CreateCommand(); insertCommand.CommandText = "BULK INSERT [MyTable] FROM '\\.\pipe\mypipe' WITH (FORMATFILE='c:\path\to\formatfile')"; insertCommand.ExecuteNonQuery();
Above bulk insert command works fine when I am bulk inserting on the same server and using \\\\.\pipe\mypipe
When I replace \\\\.\pipe\mypipe
with \\\\LocalMachineName\pipe\mypipe
, I get an error:
System.Data.SqlClient.SqlException (0x80131904): Bulk load: An unexpected end of file was encountered in the data file.
Does anyone know the reason for this error and how to fix it?