Hey Guys, In this article I will let you know how you can
create table and import data from csv file into sql server. In this process
first we create csv file with data and then use that file for create table.
Points to remember
- This functionality use only CSV and TXT file.
- When create CSV file do not left any blank cell try to delete blank cell if any in file.
Step 1
Create your CSV file with data. Your Header name will use as
a Table Field Name. You can see in below image I create file with following data.
Step 2
Open your SQL Server Management Studio. Here SQL Server
Management Studio V18.6.
Step 3
Create data base if you do not have any.
Step 4
Right click on your database name then click on Tasks and
then click on Import Flat Files.
Step 5
Now you see a wizard with some information click on Next
button.
Step 6
In this step you have three fields. Fill these fields and
then click on Next button.
- Location of your File: Select your CSV file from your computer
- New Table Name: Give your new table name must be different from other existing tables
- Schema: Select your schema
Step 7
In next step you see a preview of your file data. As you see
in below image we have same preview as our file data. Now click on Next button.
Step 8
In Next step you see a field’s name which are the headers of
your CSV file. If you want to change field name, Data type you can change here.
You can also give primary key constraint and null constraint from here. After
all changes click on next button.
Step 9
Now you see imported details. In these details following
information you can see. Verify details and then click on Finish button.
- Name: this is owner name of your computer
- Database name: Database name in which you import this file.
- Table Name: Your new table name with schema
- File to be imported: Your file path
Step 10
In this step you see a message that your data is imported. Click
on close button and close the wizard.
Below is the image of created table design and imported data.
I hope you find help from this article. If you find any help
from this share with your friends.

0 Comments