How to Import CSV into SQL Server
There are four common approaches to getting CSV data into SQL Server: BULK INSERT, the bcp command-line tool, the SSMS Import Wizard, and plain INSERT statements. Each has trade-offs in speed, flexibility, and ease of use. This guide covers all four with examples.
💡 Quick path: If you just need INSERT statements from a CSV file, use the CSV to SQL INSERT Generator — paste your CSV data and download a ready-to-run SQL script with correct T-SQL escaping and NVARCHAR types.
Method 1: BULK INSERT
BULK INSERT is the fastest native method for importing CSV files. It reads the file directly from the server's filesystem (or a network path accessible to the SQL Server service account).
BULK INSERT dbo.customers
FROM 'C:\data\customers.csv'
WITH (
FORMAT = 'CSV',
FIRSTROW = 2, -- skip header
FIELDTERMINATOR = ',',
ROWTERMINATOR = '\n',
CODEPAGE = '65001', -- UTF-8
TABLOCK
);
Limitations: BULK INSERT has limited support for quoted fields containing delimiters. If your CSV has commas inside quoted values, consider using a format file or pre-processing the data into INSERT statements with the CSV to SQL INSERT tool.
Method 2: bcp (Bulk Copy Program)
The bcp command-line utility offers similar performance to BULK INSERT and can be scripted in automated pipelines.
bcp dbo.customers in "C:\data\customers.csv" ^
-S localhost -d MyDatabase -T ^
-c -t "," -r "\n" -F 2
The -F 2 flag skips the header row, -t sets the field delimiter, and -T uses Windows authentication.
Method 3: SSMS Import Wizard
SQL Server Management Studio provides a graphical Import Flat File wizard: right-click the database → Tasks → Import Flat File. The wizard auto-detects column types, lets you preview data, and handles the import without writing any SQL. This is the easiest option for one-off imports.
Method 4: INSERT Statements
For smaller datasets or when you need full control over data transformation, generating INSERT statements is the most portable approach. The SQL runs in any client — SSMS, Azure Data Studio, sqlcmd, or application code.
INSERT INTO [dbo].[customers] ([id], [name], [email], [amount]) VALUES
(1, N'Alice Johnson', N'[email protected]', 250.00),
(2, N'Bob Smith', N'[email protected]', NULL),
(3, N'Carol Williams', N'[email protected]', 175.50);
The CSV to SQL INSERT Generator automates this: it handles escaping, NULL detection, type inference, Unicode N'' prefixes, and batching up to SQL Server's 1,000-row INSERT limit.
Choosing the Right Method
| Method | Speed | Quoted Fields | Portability |
|---|---|---|---|
| BULK INSERT | Fastest | Limited | SQL Server only |
| bcp | Fast | Limited | CLI scriptable |
| SSMS Wizard | Medium | Good | GUI only |
| INSERT statements | Slower | Full | Any SQL client |
