What Most People Miss About Exporting SQL to Excel
By David Park
Yes, you can export SQL to Excel. But if you copy-paste query results directly from SSMS or MySQL Workbench into Excel, you’ll lose leading zeros, mangle dates like '2024-03-15' into serial numbers, and silently truncate VARCHAR(2000) fields at 255 characters.
The Setup
You’re pulling customer order data from a production database for a finance review. The query returns 9 columns: CustomerID, FullName, Email, OrderDate, ShipDate, TotalAmount, Status, Region, and Notes. The Notes field contains free-text comments up to 1,800 characters — things like "Urgent: client requested expedited shipping after 2024-03-10" or "PO# ACME-7721 attached via portal."
Here’s what the raw result looks like in SQL Server Management Studio (SSMS):
CustomerID
FullName
Email
OrderDate
TotalAmount
Notes
C-8842
Sarah Chen
s.chen@acmecorp.com
2024-03-15
$45,200.00
Final approval received. PO# ACME-7721 confirmed.
C-9107
James Rivera
j.rivera@nexlogix.io
2024-03-16
$12,850.50
Client requested change to shipping address after 2024-03-10. Updated in system.
C-7731
Amina Patel
amina.patel@veridion.co
2024-03-17
$89,100.00
Urgent: client requested expedited shipping. Confirmed via call on 2024-03-14.
You need this data in Excel — not just for viewing, but for sorting by OrderDate, filtering by Region, and building a PivotTable with TotalAmount. But here’s the trap: if you highlight all rows in SSMS and paste into Excel (Ctrl+V), Excel auto-detects the first few rows and sets column formats before seeing the full dataset. It converts '2024-03-15' to 45366 (the Excel serial number), drops the leading zero in 'C-8842' if you sort later, and cuts off Notes after character 255 — even though the field contains 142 characters in row 1 and 178 in row 3.
Worse: if your query includes a calculated field like CAST(GETDATE() AS DATE), Excel pastes it as a static value *and* strips the time zone-awareness from DATETIMEOFFSET fields.
Walking Through It
Do this — not Ctrl+C/Ctrl+V.
Step 1: In SSMS, run your query. Then click Results > Save Results As…. Choose CSV (Comma delimited) (*.csv). Save as "orders_q1_2024.csv".
Step 2: Open Excel. Go to Data tab > Get Data > From Text/CSV. Navigate to your CSV file and click Import.
Step 3: In the preview window, click Transform Data. In Power Query Editor, select the OrderDate column. Right-click > Change Type > Date. Do the same for TotalAmount → Decimal Number. For Notes, right-click > Change Type > Text.
Step 4: Select CustomerID. Right-click > Change Type > Text. This prevents Excel from converting 'C-8842' to a number or dropping the dash.
Step 5: Click Close & Load. Excel loads the data into a new worksheet starting at A1.
Before (what happens with Ctrl+V):
A1
B1
C1
D1
E1
F1
C-8842
Sarah Chen
s.chen@acmecorp.com
45366
45200
Final approval received. PO# ACME-7721 confir
After (Power Query import):
A1
B1
C1
D1
E1
F1
C-8842
Sarah Chen
s.chen@acmecorp.com
2024-03-15
45200.00
Final approval received. PO# ACME-7721 confirmed.
Counterintuitive tip: Never use "Paste Special > Text". It still triggers Excel’s auto-formatting engine. CSV + Power Query is the only reliable path.
The Result
Your final Excel sheet starts at A1 with clean, typed data. OrderDate is a true Date (not text or serial), so you can sort chronologically and build timelines. CustomerID stays as text — no accidental math or zero-truncation. Notes shows full content. And because Power Query loaded it as a Table (Ctrl+T), you get structured references like Orders[TotalAmount] for formulas.
A1
B1
C1
D1
E1
F1
C-8842
Sarah Chen
s.chen@acmecorp.com
2024-03-15
$45,200.00
Final approval received. PO# ACME-7721 confirmed.
C-9107
James Rivera
j.rivera@nexlogix.io
2024-03-16
$12,850.50
Client requested change to shipping address after 2024-03-10. Updated in system.
C-7731
Amina Patel
amina.patel@veridion.co
2024-03-17
$89,100.00
Urgent: client requested expedited shipping. Confirmed via call on 2024-03-14.
PO# BM-2024-Q3-0914 attached. Approved by finance on 2024-03-15.
What Could Go Wrong
Mistake #1: Using “Copy with Headers” from SSMS and pasting into a blank workbook. Excel treats the first row as labels and applies AutoFit — which resizes column widths *before* loading full text. Notes gets cut at ~120 chars. Fix: Always use CSV + Power Query.
Mistake #2: Opening the CSV directly by double-clicking it. Windows opens it in Excel using the default text import wizard — which guesses types based on first 8 rows only. If your first 8 OrderDate values are all in 2024, it may fail on '2023-12-01' later. Fix: Import via Data > From Text/CSV, never double-click.
Mistake #3: Forgetting to set CustomerID to Text *before* loading. Excel sees 'C-001' and 'C-002' and converts them to 'C-1', 'C-2'. You’ll notice it when sorting — C-10 appears before C-2. Fix: In Power Query, select CustomerID column > Transform tab > Data Type > Text.
Here’s your action checklist:
Step
Action
Keyboard Shortcut
1
Save SSMS results as CSV
Alt+F+A
2
In Excel: Data > From Text/CSV
Alt+A+T
3
In Power Query: Select column > Transform > Data Type > [correct type]
Alt+D+T
4
Click Close & Load
Alt+F+C
David Park
David brings deep expertise in office supply evaluation and procurement. He has tested hundreds of products to help teams make informed purchasing decisions.