Saturday, August 2, 2014

SQL Server Bulk Insert Example

Below is screenshot of Employee table that I will use to insert using SQL bulk insert rows from CSV file.

SQL Bulk Insert

SQL Bulk Insert CSV File

In this tutorial we will use very simple CSV file that will contain Employee information. See below screenshot of EmployeeBulkInsert.csv file.

SQL Bulk Insert Employee
The CSV file will be loaded from C:\ location so I will use C:\EmployeeBulkImport.csv to import the CSV file.

SQL Bulk Insert example

I will now show you how to use SQL Bulk Insert command to import this very simple CSV file.

BULK INSERT dbo.Employee
FROM 'c:\EmployeeBulkInsert.csv'
WITH
(
FIELDTERMINATOR = ',',
ROWTERMINATOR = '\n'
)

Below is screenshot with command and results

SQL Bulk insert example

No comments:

Post a Comment