Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Power BI Data Visualization World Championships is back! It's time to submit your entry. Live now!

Reply
Rufyda
Super User
Super User

CSV Export from SQL Server Does Not Include Column Headers

I have data stored in SQL Server.
When I run a query with specific filters and export the result to a CSV file, the exported file contains only data rows without column names (headers).

Because of this:

When I use Get Data → CSV in Power BI / Microsoft Fabric,

The dataset is loaded without column names, and the first row is treated as data.

Expected Behavior

The exported CSV file should include column headers, so that Power BI / Fabric can correctly recognize the column names.

Actual Behavior

CSV file contains data only

No column headers

Power BI / Fabric does not detect column names

Environment

SQL Server

SQL Server Management Studio (SSMS)

Power BI / Microsoft Fabric

>>>>>>>>>>>>>>>>>>>

What is the recommended way in Microsoft Fabric to:

Export query results from SQL Server to CSV with column headers, or

Ingest SQL Server query results into Fabric / Power BI without losing column names?


Rufyda_0-1768769175558.png



Rufyda_1-1768769207334.png

 

2 ACCEPTED SOLUTIONS
Amar_Kumar
Super User
Super User

@Rufyda This is not a Power BI / Fabric issue. It comes from how the CSV is being generated from SQL Server.

Recommended approaches

1. Do not export to CSV manually
Best practice is to connect Fabric / Power BI directly to SQL Server:

  • Use SQL Server connector

  • Use a view or native SQL query
    This preserves column names and data types automatically.

2. If you must generate a CSV, use a tool that includes headers
SSMS “Save Results As CSV” does not reliably include headers.

Better options:

  • bcp with -h option

  • sqlcmd with headers enabled

  • SSIS or Fabric Data Factory pipeline

Example (sqlcmd):

sqlcmd -S ServerName -d DatabaseName -Q "SELECT ..." -s "," -W -o output.csv

3. Use Fabric Data Factory / Pipelines
Recommended Fabric-native solution:

  • Source: SQL Server

  • Sink: Lakehouse / Files (CSV)

  • Enable “First row as header”
    This guarantees headers and avoids CSV issues entirely.

4. Power BI workaround (not ideal)
In Power Query:

  • Manually promote first row to headers
    This only works if the first row actually contains column names.

View solution in original post

Rufyda
Super User
Super User

Rufyda_0-1768902671604.png

Thank you to everyone for the helpful suggestions 🙏

I wanted to share the final resolution in case someone else faces the same issue.
The problem was not related to Power BI or Microsoft Fabric, but rather to SSMS settings.

In SQL Server Management Studio (SSMS), when exporting query results to CSV:

Go to Tools → Options

Then Query Results → SQL Server → Results to Grid / Results to Text

Enable “Include column headers when copying or saving the results”

After enabling this option, the exported CSV file included the column headers correctly, and Power BI / Fabric recognized the columns without any issues.

Hope this helps someone facing the same problem 👍

View solution in original post

3 REPLIES 3
Rufyda
Super User
Super User

Rufyda_0-1768902671604.png

Thank you to everyone for the helpful suggestions 🙏

I wanted to share the final resolution in case someone else faces the same issue.
The problem was not related to Power BI or Microsoft Fabric, but rather to SSMS settings.

In SQL Server Management Studio (SSMS), when exporting query results to CSV:

Go to Tools → Options

Then Query Results → SQL Server → Results to Grid / Results to Text

Enable “Include column headers when copying or saving the results”

After enabling this option, the exported CSV file included the column headers correctly, and Power BI / Fabric recognized the columns without any issues.

Hope this helps someone facing the same problem 👍

krishnakanth240
Impactful Individual
Impactful Individual

Hi @Rufyda 

 

You can connect directly to SQL Server connector in Power BI / Fabric by writing your query in Advanced options. Column names will populate.

 

Also, using Fabric Dataflow Gen2 or Pipeline with SQL Server source and using either a query or table sinking to lakehouse.

Amar_Kumar
Super User
Super User

@Rufyda This is not a Power BI / Fabric issue. It comes from how the CSV is being generated from SQL Server.

Recommended approaches

1. Do not export to CSV manually
Best practice is to connect Fabric / Power BI directly to SQL Server:

  • Use SQL Server connector

  • Use a view or native SQL query
    This preserves column names and data types automatically.

2. If you must generate a CSV, use a tool that includes headers
SSMS “Save Results As CSV” does not reliably include headers.

Better options:

  • bcp with -h option

  • sqlcmd with headers enabled

  • SSIS or Fabric Data Factory pipeline

Example (sqlcmd):

sqlcmd -S ServerName -d DatabaseName -Q "SELECT ..." -s "," -W -o output.csv

3. Use Fabric Data Factory / Pipelines
Recommended Fabric-native solution:

  • Source: SQL Server

  • Sink: Lakehouse / Files (CSV)

  • Enable “First row as header”
    This guarantees headers and avoids CSV issues entirely.

4. Power BI workaround (not ideal)
In Power Query:

  • Manually promote first row to headers
    This only works if the first row actually contains column names.

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! It's time to submit your entry.

January Power BI Update Carousel

Power BI Monthly Update - January 2026

Check out the January 2026 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.