Error out of memory when importing flat file SQL-Server

Donald Trung 1 Reputation point
2023-01-03T03:39:20.4+00:00

I am importing flat file (both txt and csv) into SQL Server. Such file has more 1.7 mil rows. When importing, has error like screenshot below. Pls kindly share how to solve this. Much appreciated !

275492-error-in-importing-flat-file.png

SQL Server | Other
{count} votes

1 answer

Sort by: Most helpful
  1. Seeya Xi-MSFT 16,586 Reputation points
    2023-01-03T07:00:33.173+00:00

    Hi @Donald Trung ,

    Welcome to Microsoft Q&A!

    Exception of type 'System.OutOfMemoryException' was thrown

    This error indicates that Management Studio is running out of memory, not the SQL Server service. Even if you installed 64-bit SQL Server, the SQL Server Management Studio executable is a 32-bit application. Therefore, it is limited to 2 GB of memory.
    Please refer to this document: Exception when you execute a query in SQL Server Management Studio
    Here is a method you can take:
    Use sqlcmd Utility instead of SSMS to run the SQL queries. This method enables queries to be run without the resources that are required by the SSMS UI. Additionally, you can use the 64-bit version of Sqlcmd.exe to avoid the memory restriction that affects the 32-bit SSMS process.

    Best regards,
    Seeya


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    1 person found this answer helpful.
    0 comments No comments

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.