SQL SERVER Crashing while using OPENROWSET to import csv files

Zhu, Weide (Sydney) 0 Reputation points
2023-05-11T23:38:22.1933333+00:00

Hello,

We keep getting the following error and SQL crashes when we try to use OPENROWSET to import csv files into SQL DB. This is an intermittent problem and below is the SQL log . Note this issue occurs in almost every machine.

So I am just wondering if this is a known issue using OpenROWSET and shall we continue to use OPENROWSET?

2023-05-11 13:57:29.25 Server Error: 17311, Severity: 16, State: 1.

2023-05-11 13:57:29.25 Server SQL Server is terminating because of fatal exception c0000005. This error may be caused by an unhandled Win32 or C++ exception, or by an access violation encountered during exception handling. Check the SQL error log for any related stack dumps or messages. This exception forces SQL Server to shutdown. To recover from this error, restart the server (unless SQLAgent is configured to auto restart).

output from select @@VERSION

Microsoft SQL Server 2019 (RTM-CU20) (KB5024276) - 15.0.4312.2 (X64) Apr 1 2023 12:10:46 Copyright (C) 2019 Microsoft Corporation Developer Edition (64-bit) on Windows 10 Enterprise 10.0 <X64> (Build 19044: ) (Hypervisor)

SQL Server | Other
{count} votes

1 answer

Sort by: Most helpful
  1. Erland Sommarskog 121.4K Reputation points MVP Volunteer Moderator
    2023-05-15T21:32:19.26+00:00

    How is the OLE DB provider configured with regards to Allow in-process? It may be better to have this option unchecked. In that case, accidents in the OLE DB provider cannot affect SQL Server.

    Then again, an access violation is an access violation and that is a bug. And whether it is in SQL Server or the OLE DB provider is immaterial, since both are Microsoft products. That is, you could open a support case, and it should not be of any cost for you.

    However, I can't say that I am enthusiastic over using the ACE provider to read CSV files. I would rather read the file with BULK INSERT which has a CSV option. You can also use OPENROWSET(BULK). Since they don't permit the file name to be dynamic, you would have to dabble with dynamic SQL, though.

    And because of this option, the chances that you will get a fix if you open a support case may not be that bright, since they may find the bulk option to be a satisfactory workaround.

    1 person found this answer helpful.

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.