Recommended method to import a .csv file into Microsoft SQL Server 2008 R2?

前端 未结 6 1004
陌清茗
陌清茗 2021-01-02 04:21

What is your recommended way to import .csv files into Microsoft SQL Server 2008 R2?

I\'d like something fast, as I have a directory with a lot of .csv files (>500MB

6条回答
  •  孤独总比滥情好
    2021-01-02 05:02

    I understand this is not exactly your question. But, if you get into a situation where you use a straight insert use tablock and insert multiple rows. Depends on the row size but I usually go for 600-800 rows at at time. If it is a load into an empty table then sometimes dropping the indexes and creating them after it is loaded is faster. If you can sort the data on the clustered index before it is loaded. Use IGNORE_CONSTRAINTS and IGNORE_TRIGGERS if you can. Put the database in single user mode if you can.

    USE AdventureWorks2008R2; GO INSERT INTO Production.UnitMeasure with (tablock) VALUES (N'FT2', N'Square Feet ', '20080923'), (N'Y', N'Yards', '20080923'), (N'Y3', N'Cubic Yards', '20080923'); GO

提交回复
热议问题