Bulk Insert Command In SQL Server 2008

In this article I describe about bulk insert command in SQL Server.
  • 2024

In this article I describe about bulk insert command in SQL Server. Bulk Insert command can be executed within stored procedure or T-SQL script to import data in to SQL Server.

Create Table



Emp_FirstName varchar (100) NOT NULL,

Emp_LastName varchar (100) NOT NULL,

Email varchar (100) NOT NULL


Student Table

select * from Student


Till now data is not inserted in table.

Bulk Insert Command

Suppose we have a text file named StudentDetails.Text  which contains large amount of data. Now we want to insert it in our database. Column Name must be same that you have data in text file.  Bulk Insert command inserts data from text file into destination table by using one-to-one mapping.

If destination table has too many columns then this method may no work, it will fail. The file location of the source comma-delimited file, and the options are passed as a parameter of the command specify the table receiving the data.


Suppose we have StudentDetails.Txt file.


To insert data from StudentDetails.Txt file in Student table, write following query.

BULK INSERT Student FROM 'd:\bulkInsert.txt' WITH (FIELDTERMINATOR = ',')

Now select Student table records.

select * from Student


Note: While using Bulk Insert command, it will more helpful to open the source file using Excel file.


More Articles

© 2020 DotNetHeaven. All rights reserved.