Best practices for importing large CSV files

前端 未结 10 853
攒了一身酷
攒了一身酷 2020-12-14 16:39

My company gets a set of CSV files full of bank account info each month that I need to import into a database. Some of these files can be pretty big. For example, one is abo

10条回答
  •  轮回少年
    2020-12-14 17:18

    Forgive me if I'm not exactly understanding your issue correctly, but it seems like you're just trying to get a large amount of CSV data into a SQL database. Is there any reason why you want to use a web app or other code to process the CSV data into INSERT statements? I've had success importing large amounts of CSV data into SQL Server Express (free version) using SQL Server Management Studio and using BULK INSERT statements. A simple bulk insert would look like this:

    BULK INSERT [Company].[Transactions]
        FROM "C:\Bank Files\TransactionLog.csv"
        WITH
        (
            FIELDTERMINATOR = '|',
            ROWTERMINATOR = '\n',
            MAXERRORS = 0,
            DATAFILETYPE = 'widechar',
            KEEPIDENTITY
        )
    GO
    

提交回复
热议问题