0% found this document useful (0 votes)
2 views

Import csv into SQL server

The document outlines the process of importing CSV files into SQL Server using SQL Server Management Studio (SSMS). It details the steps to convert Excel files to CSV format and provides a step-by-step guide for importing the CSV file, including selecting the database, previewing data, and mapping data types. The document emphasizes the importance of proper data type mapping to avoid conversion errors during the import process.

Uploaded by

Abhishek Kore
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Import csv into SQL server

The document outlines the process of importing CSV files into SQL Server using SQL Server Management Studio (SSMS). It details the steps to convert Excel files to CSV format and provides a step-by-step guide for importing the CSV file, including selecting the database, previewing data, and mapping data types. The document emphasizes the importance of proper data type mapping to avoid conversion errors during the import process.

Uploaded by

Abhishek Kore
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 8

Import csv into SQL server (with query OR without query using SSMS)

While creating a database, your client may need to save old data in new database and he
has asked you to import his excel sheet file into SQL server database, or you already have
some data in excels sheet that excel you need to convert in .csv file and needs to import it,
then we can have one possible ways using SQL server management studio (SSMS) GUI
options, let's take a look on each of them one by one.

 Important Point :
We did not Import excel sheet old data or mix data with symbol, sign,
character, Number Directly. We are importing table with the help of SQL
Server Import and Export Wizard tool, but table not showing data in table they
showing Null or blank cell in Table that’s why we have alternate option to
convert excel file to .csv file and import with flat file

Convert XLS to CSV

You can convert an Excel worksheet to a .Csv file by using the Save As command. Go to
File > Save As. Click Browse. In the Save As dialog box, under Save as type box, choose
the .csv file format for the worksheet; for example, click CSV (Comma delimited).

Import CSV file into SQL server using SQL server management Studio
1. Step 1: Select database, right-click on it -> "Tasks"->Select "Import flat file" ...
2. Step 2: Browse file and give table name. ...
3. Step 3: Preview data before saving it. ...
4. Step 4: Check Data-type and map it properly, to successfully import csv.

Methods in SQL Server to Import CSV in Details:

Import CSV file into SQL server using SQL server management Studio
In this process, we will use SQL server management studio GUI to import csv file in sql
server database table, as bulk copy and other bulk import options are not available on the
SQL servers, then this GUI based option is good and easy for large CSV files, since it
allows you to import data, step by step and more easily.

Step 1: Select database, right-click on it -> "Tasks"->Select "Import flat file"

At first, open your SQL server management studio, and select the database ( in this case
"OrderDetails") and then right-click on it, after right-clicking on it, select "Tasks"-> Select
"Import flat file"

1|Page
Now, once you select "Import flat file" a new dialog box, will open, click "Next"

2|Page
Step 2: Browse file and give table name

Clicking "next", will bring the new screen, using which we need to select the "csv" file to be
imported, so click on "Browse", locate the .csv file and give table name.

Note: Table name muste be unique, means that table should be new table ( not already
created table )

3|Page
Step 3: Preview data before saving it

Once, you will click next after selecting file, you can preview the data before saving it into
table, considering above CSV file, we have can preview like below

4|Page
As you can see in the above image, we can see CSV data in preview, you can click on
"Next"

Step 4: Check Data-type and map it properly, to successfully import csv

Now, you need to map csv file columns with database columns type properly, as shown in
the below image

5|Page
You can change data-type, as per your csv file, once done, click "Next"

Note: you need to map data-type with columns properly, otherwise you will get conversion
error.
Step 5: Check details and click finish

Once you are done with data mapping, you can verify details and click "Finish", data will be
imported, with creation of table.

6|Page
Click "Finish" and in the next Screen you will see, data has been imported successfully ( if
there is any error, you will see error and can check error.), then click "Close".

7|Page
You can refresh the tables of database, select table, it will show all the data imported
properly.

8|Page

You might also like