Error when using C# class SqlBulkCopy to write to table with ColumnStore index

44 Views Asked by At

I have this simple code that bulk copy a DataTable:

private async Task BulkCopyTableAsync(SqlConnection dbConnection, SqlTransaction sqlTransaction, DataTable table)
{
    using (SqlBulkCopy s = new SqlBulkCopy(dbConnection, SqlBulkCopyOptions.Default, sqlTransaction))
    {
        s.BulkCopyTimeout = 3600;
        s.DestinationTableName = table.TableName;
        s.BatchSize = 1048576;

        foreach (var column in table.Columns)
            s.ColumnMappings.Add(column.ToString(), column.ToString());

        await s.WriteToServerAsync(table);
    }
}

It works fine when my table has a clustered primary key, but I end up with an error when I use a clustered columnstore index.

The error is:

A system assertion check has failed. Check the SQL Server error log for details. Typically, an assertion failure is caused by a software bug or data corruption. To check for database corruption, consider running DBCC CHECKDB. If you agreed to send dumps to Microsoft during setup, a mini dump will be sent to Microsoft. An update might be available from Microsoft in the latest Service Pack or in a Hotfix from Technical Support. Cannot continue the execution because the session is in the kill state. A severe error occurred on the current command. The results, if any, should be discarded.

Location: "Sql\Ntdbms\storeng\dfs\access\columnstoreorphan.cpp":995
Expression: context S
PID: 84
Process ID: 2272
Thread ID: 10080

Does someone knows what can cause this error?

0

There are 0 best solutions below