Bulk Insert Operations into database using query

We can insert bulk  operations into table on database using the following query.

The bulk data is inserted through any external files like (.csv,.doc,.xls etc).

The following example shows bulk insert operations through comma separated value (.csv) file.

Syntax:

bulk insert <table-name>
from ‘csv file path’
with
( fieldterminator=’,’,              // In csv file fieldterminator is camma { , }  
rowterminator=’\n’                // Rowterminator is new line { \n } 
)

Example:

bulk insert emp
from ‘D:\bulkinsert.csv’
with
( fieldterminator=’,’,
rowterminator=’\n’
)

 

Note: When we insert bulk operations on table into database, first we need to create .csv file on desired path.

The above example in D drive bulkinsert.csv  file must be available. { D:\bulkinsert.csv }.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s