3

I am getting error while inserting flat file into SQL Server. Direct transfer from SQL Server to SQL Server is not possible. Data has to be exported and then imported. Note : Data was exported from SQL server with text qualifier "double quotes" and pipe delimited "|". I tried to re-extract the data using fixed width format still unable to import. Please assist.

Error Message :

Error inserting data into table. (Microsoft.SqlServer.Import.Wizard)

------------------------------
Program Location:



 at Microsoft.SqlServer.Import.Wizard.InsertData.ResultCheck(Result result)
   at Microsoft.SqlServer.Import.Wizard.InsertData.DoWork()
   at Microsoft.SqlServer.Management.TaskForms.SimpleWorkItem.Run()

===================================

Error inserting data into table. (Microsoft.SqlServer.Prose.Import)

------------------------------
Program Location:

   at Microsoft.SqlServer.Prose.Import.BcpSynthesis.InsertIntoDB(String inputFilePath, String tableName, String schemaName, SqlConnection connection, Int32 batchSize, SqlTransaction transaction)
   at Microsoft.SqlServer.Prose.Import.BcpProcess.<>c__DisplayClass42_0.<InsertIntoDb>b__0()
   at Microsoft.SqlServer.Prose.Import.BcpProcess.ExecuteOperation(Action operation)

===================================

Object reference not set to an instance of an object. (Microsoft.SqlServer.Prose.Import)

------------------------------
Program Location:

   at Microsoft.SqlServer.Prose.Import.OutputDataReader.GetValue(Int32 i)
   at System.Data.SqlClient.SqlBulkCopy.GetValueFromSourceRow(Int32 destRowIndex, Boolean& isSqlType, Boolean& isDataFeed, Boolean& isNull)
   at System.Data.SqlClient.SqlBulkCopy.ReadWriteColumnValueAsync(Int32 col)
   at System.Data.SqlClient.SqlBulkCopy.CopyColumnsAsync(Int32 col, TaskCompletionSource`1 source)
   at System.Data.SqlClient.SqlBulkCopy.CopyRowsAsync(Int32 rowsSoFar, Int32 totalRows, CancellationToken cts, TaskCompletionSource`1 source)
   at System.Data.SqlClient.SqlBulkCopy.CopyBatchesAsyncContinued(BulkCopySimpleResultSet internalResults, String updateBulkCommandText, CancellationToken cts, TaskCompletionSource`1 source)
   at System.Data.SqlClient.SqlBulkCopy.CopyBatchesAsync(BulkCopySimpleResultSet internalResults, String updateBulkCommandText, CancellationToken cts, TaskCompletionSource`1 source)
   at System.Data.SqlClient.SqlBulkCopy.WriteToServerInternalRestContinuedAsync(BulkCopySimpleResultSet internalResults, CancellationToken cts, TaskCompletionSource`1 source)
   at System.Data.SqlClient.SqlBulkCopy.WriteToServerInternalRestAsync(CancellationToken cts, TaskCompletionSource`1 source)
   at System.Data.SqlClient.SqlBulkCopy.WriteToServerInternalAsync(CancellationToken ctoken)
   at System.Data.SqlClient.SqlBulkCopy.WriteRowSourceToServerAsync(Int32 columnCount, CancellationToken ctoken)
   at System.Data.SqlClient.SqlBulkCopy.WriteToServer(IDataReader reader)
   at Microsoft.SqlServer.Prose.Import.BcpSynthesis.InsertIntoDB(String inputFilePath, String tableName, String schemaName, SqlConnection connection, Int32 batchSize, SqlTransaction transaction)
rachel
  • 225
  • 2
  • 5
  • 16
  • Is your question "How do I use the SQL Server Import Wizard to import my file?" or is it "How can I import this file?" – rd_nielsen Mar 24 '19 at 02:15
  • I know how to import using SQL Server Wizard. When i try to import using the wizard, It fails and throws the error mentioned in the post. – rachel Mar 24 '19 at 02:47
  • If you are determined to use the import wizard, you should provide examples of your data. If you are amenable to using alternative (and better) tools, you should post a question at https://softwarerecs.stackexchange.com/. The only real hint at the source of the problem in that voluminous error message is that the failure occurred when trying to read an integer. You may have a column of data that the wizard decided was integer data, but that is not really integer data. – rd_nielsen Mar 24 '19 at 03:04
  • To avoid data type issues, i am importing everything as nvarchar. – rachel Mar 24 '19 at 20:41

0 Answers0