Friday , November 22 2024

BULK INSERT in SQL Server

With BULK INSERT you can upload text, csv data files to the database in any format. Users must have insert privileges in the database and ADMINISTER BULK OPERATIONS privileges on the server level to perform BULK INSERT .

Below you can see the sample usage of BULK INSERT.

First, we create a text file as below.

Then we create a table with the help of the following script to save this text file into the database.

Then, with the help of the following script, we transfer the data in this text file to our table in the database.

Explanation of parameters in the script:

DATAFILETYPE is the type of data,

FIELDTERMINATOR is column separator,

ROWTERMINATOR is row separator

Then we will see the records in the table as follows.

You can use the following article for importing data to SQL Server and exporting data from SQL Server

How To Import Excel To SQL Server Table“,

How To Export SQL Server Table To Excel“,

How To Export SQL Server Table to CSV File“,

How to Import Images to SQL Server with TSQL Codes“,

How To Import/Export from SQL Server Database to SQL Server Database“,

Loading

About dbtut

We are a team with over 10 years of database management and BI experience. Our Expertises: Oracle, SQL Server, PostgreSQL, MySQL, MongoDB, Elasticsearch, Kibana, Grafana.

Leave a Reply

Your email address will not be published. Required fields are marked *