Home » Import file in SQL server

Import file in SQL server

Import csv file in SQL Server database table




Using SQL Server Management Studio, you can easily import file data in SQL Server database.

As you can see, here we have one CSV file named as Data.CSV.

 

This file is located inside system Folder Inputfile.

 

 

 

 

Now we will import this file data into SQL Server data base(version 2019) table.

Following are the step to load csv file data into sql server table.

1> Right click on database where you want to load file data >Then, Click on Tasks context menu > Next, Import Flat File ( This option is for .CSV ,or  .txt format files)

 

After that you will see , an introduction pop window opens.

2> Click on, Specify input file > Choose file that you want to load in table> Specify table name, we have taken InputDatFile and choose schema. This table will be used to load input file data.

After that click on NEXT button.

 

 

3> Now preview data window opens, here you can see sample of data, so that you can validate that you have choose correct file or how does your data look like in tabluar format.

After that click on NEXT button.

 

4> Once you click on NEXT button, a Modify columns window open , here you can make changes in column data type ,set primary key columns so on.. as per your requirement.

Once you done with that , click on NEXT button.

 

 

5> After that , it displays you summary of you inputs like input file names, database name and table name just to validate that you have choosen right file or not .

After that just click on FINISH button to complete final step.

 

 

Once you click on finish button, it starts loading file data into table. When loading is completed,

You will get a success message in dialog box.

 

Now you can check whether the records is inserted or not in table that you have given.

SELECT * FROM InputDataFile

As you can see, now you have imported CSV file data into SQL table,  and table having same records as you had in your input file.




Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.