Fastest way to transfer Excel table data to SQL 2008R2

后端 未结 6 745
囚心锁ツ
囚心锁ツ 2021-02-15 01:52

Does anyone know the fastest way to get data from and Excel table (VBA Array) to a table on SQL 2008 without using an external utility (i.e. bcp)? Keep in mind my datas

6条回答
  •  星月不相逢
    2021-02-15 02:04

    By far the fastest way to do this is via T-SQL's BULK INSERT.

    There are a few caveats.

    • You will likely need to export your data to a csv first (you may be able to import directly from Excel; my experience is in going from Access .mdbs to SQL Server which requires the interim step to csv).
    • The SQL Server machine needs to have access to that csv (when you run the BULK INSERT command and specify a filename, remember that the filename will be resolved on the machine where SQL Server is running).
    • You may need to tweak the default FIELDTERMINATOR and ROWTERMINATOR values to match your CSV.

    It took some trial and error for me to get this set up initially, but the performance increase was phenomenal compared to every other technique I had tried.

提交回复
热议问题