Cours informatiques gratuits en ligne
Depuis plus de 20 ans Polymorphe.org vous propose de télécharger gratuitement des cours et des articles de référence sur différents domaines informatiques.
Etoiles inactivesEtoiles inactivesEtoiles inactivesEtoiles inactivesEtoiles inactives
 

Export data from SQL Server as fast as possible

Exporting large volumes of data from SQL Server is a common requirement for analytics, data migration, backups, or data sharing. However, not all export tools deliver the same performance, scalability, or ease of use.

In this article, we compare several common approaches using the TPC-H orders table as a benchmark:

  • BCP (CLI – native SQL Server tool)
  • SSIS (No-code ETL)
  • sqlcmd (CLI – scripting oriented)
  • FastBCP (CLI – high-performance parallel exporter)


Test context

We use the TPC-H orders table, typically containing millions of rows:


SELECT COUNT(*) FROM dbo.orders; ==> 15M Rows
 

Assumptions:

  • SQL Server 2019+
  • Export to CSV format
  • Local SSD storage
  • Minimal transformation (raw export)


1. BCP (Bulk Copy Program)

BCP is the historical command-line tool provided by Microsoft. It is fast, lightweight, and reliable, but limited to single-threaded exports.

BCP export command

  

bcp "SELECT * FROM dbo.orders_15M" `
queryout D:\temp\orders_bcp.csv `
-c `
-t ";" `
-r "\n" `
-S localhost `
-d tpch_test `
-T -u
 

Pros

  • Fast for single-threaded export
  • No additional dependencies
  • Stable and well-known

Cons

  • No parallelism
  • No Header :-(
  • Limited control over formatting
  • Limited log output or too long
  • No compression
  • No partitioning output
  • Export only locally
  • Export only CSV or SQL binary format
  • Only SQL Server

BCP MSSQL to CSV Local Command Results


2. SSIS (SQL Server Integration Services)

SSIS is a graphical ETL tool suitable for non-developers and complex pipelines. It can reach good performance but requires more setup and infrastructure.

Typical SSIS flow

  • OLE DB Source → orders table
  • Flat File Destination → CSV

Key performance settings:

  • Appropriate DefaultBufferMaxRows
  • Minimal transformations

Pros

  • No code required
  • Scheduling
  • Logging
  • Monitoring
  • Work for many databases
  • Can make complex transformations

Cons

  • No parallelism
  • Heavier infrastructure (service, database
  • Slow Dev
  • Slow to scale to hundreds of tables
  • Lower raw performance than CLI tools
  • Not ideal for simple exports
  • Export only locally

 

SSIS MSSQL to CSV 2025 12 29 01h26 23 SSIS and CSV columns definition  

 

SSIS MSSQL to CSV Results Time

 


3. sqlcmd

sqlcmd is a scripting-oriented CLI tool. It is flexible but not designed for high-volume exports.

sqlcmd export command


measure-command {sqlcmd -S localhost -d tpch_test -E `
-Q "SET NOCOUNT ON; SELECT * FROM dbo.orders_15M" ` -o D:\temp\orders_sqlcmd.csv ` -s ";" -W
}


  

Pros

  • Very simple
  • Good for automation scripts
  • No additional tooling

Cons

  • No parallelism
  • No Logs
  • Bad Header : need some trick to remove the 2nd line
  • Only work with SQL Server
  • Export only locally

sqlcmd csv export


4. FastBCP (High-performance parallel export)

FastBCP is a modern CLI tool designed specifically for maximum export speed. It uses parallel extraction to fully leverage modern CPUs and storage.

Official website: https://fastbcp.arpe.io

FastBCP export command


.\FastBCP.exe `
--connectiontype "mssql" `
--server "localhost" `
--database "tpch_test" `
--trusted `
--sourceschema "dbo" `
--sourcetable "orders_15M" `
--query "SELECT * FROM dbo.orders_15M" `
--directory "D:\Data\fastbcpexport\raw\{sourcedatabase}\{sourceschema}\" `
--fileoutput "{sourcetable}.csv" `
--decimalseparator "." `
--delimiter ";" `
--dateformat "yyyy-MM-dd HH:mm:ss" `
--encoding "UTF-8" `
--method "RangeId" `
--distributekeycolumn "o_orderkey" `
--paralleldegree -2 `
--merge false

Key concepts

  • Table\Query can be splitted using a parallel method
  • Multiple concurrent readers
  • Linear scalability with CPU cores

Pros

  • Much faster than BCP, SSIS and sqlcmd
  • True parallelism
  • Simple CLI usage
  • Clean header without headacke
  • Drivers included
  • Templating for output files names and directories
  • Work on other databases (Oracle, MySQL, PostgreSQL, Netezza, ODBC...)
  • No installation (just copy the .exe file)
  • Works on windows and linux
  • Can also export to cloud (AWS S3, S3 compatibles, Azure (ABS & ADLS), GCS, OneLake)

Cons

  • External tool
  • Can be cpu intensive (but this is what you want to go faster)

FastBCP MSSQL to CSV Local Command

 

FastBCP MSSQL to CSV Local Results


Performance comparison (typical results)

ToolSpeedDev TimeParallelComplexityLimited to SQL Server
sqlcmd Slow (38s) Fast (30s) No Low

Yes

SSIS Slow (39s) Slow (10min) No High No
BCP fast (21s) Fast (30s) No Low Yes
FastBCP Very fast (3s) Fast (30s) Yes Low No


Conclusion

If you need a quick and simple export, BCP remains a solid choice. For complex ETL pipelines and workflows, SSIS is appropriate. For scripting, sqlcmd is convenient but some issue and limitated to SQL Server.

However, when the objective is exporting large SQL Server tables as fast as possible, FastBCP clearly stands out thanks to its parallel architecture and CLI simplicity. Bonus it can do the same for many other databases and format (parquet, json , xlsx)

 

Ajouter vos commentaires

Poster un commentaire en tant qu'invité

0 / 30000 Restriction des caractères
Votre texte doit contenir entre 10 et 30000 caractères
Vos commentaires sont soumis à la modération de l'administrateur.
conditions d'utilisation.
  • Aucun commentaire trouvé

Redac Team

Romain Ferraton

Romain Ferraton Architecte DWH & Cloud

Romain est le fondateur de Polymorphe.org et le récent créateur et CEO de la société Architecture & Performance

linkedin

Sylvain Baduel

Sylvain Baduel Chef de projet décisionnel

Sylvain est chef de projet décisionnel chez Imerys TC, il s'occupe des traitements d'intégration ETL Datastage, de l'entrepôt de données sous Oracle, de la platefome BI SAP BO BI4 et de nombreux autres projets.. Il est rédacteur sur Polymorphe.org : un grand merci à lui.

linkedin

Eric Duquesnoy

Eric Duquesnoy DataSpace Architect

Eric est un architecte de solution pour héberger les données, DBA dans une autre vie il a su prendre la vague du Big Data et du NoSQL tout ca pour le plus grand bonheur des données. Eric intervient en tant que rédacteur sur Polymorphe.org

linkedin

François Pacull

François Pacull Data Scientist

François a rejoint Architecture & Performance et il publie sur Polymorphe.org des articles sur le Machine Learning, le Deep Learning et l'optimisation de programmes

linkedin

Vous ici

Et si vous participiez ?

Inscrivez vous !