what is the best way to import excel data to one of the Database table in Sql Server
Loading
what is the best way to import excel data to one of the Database table in Sql Server
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Nikunj SatasiyaRank #302 · 8.3K reputationPosted Jul 25, 2024, 4:16 AM EDT
Abhishek, you can take refrence from my article.
Article Link:
https://www.codingvila.com/2021/02/upload-and-read-excel-file-in-web-api.html
Ivonne AspilcuetaRank #4,887 · 320 reputationPosted Jul 24, 2024, 5:50 PM EDT
1) Make sure your spreadsheet is clean and all columns align to the correct data (Make sure there are no strings of data out of place).
2) Create a Database or existing Database, avoid to use the system databases.
3) right click on the base, choose: Task - Import Flat File and follow the instructions.
For existing Tables:
1) Make sure your spreadtsheet matches columns names and datatype from SQL Table
2) right click on the databse where your existing tables is and choose Task- Import data.
3) Export wizard, click next and choose your data source: Microsoft Excel and upload your file.
4) Follow instructions
Abhishek ChadhaRank #402 · 6.2K reputationPosted Jul 24, 2024, 9:48 PM EDT
For existing tables - by this way can we import just one table
Ivonne AspilcuetaRank #4,887 · 320 reputationPosted Jul 25, 2024, 11:43 AM EDT
Hi!
Yes, those steps I explained below the comments are for one table, but if you are looking to add data for multiple tables what you can do is:
Instead of importing the excel to a table in SQL, import it into a Temp table on SQL server. Then you will be able to write a query which retrieves all the data from the Temp table, to make joins it to the other tables and then inserts into those tables if you have a relational database.
OR multiple excel
You can use SSIS:
https://www.youtube.com/watch?v=gAJUt65_Tcs
Vishal YelveRank #178 · 13.6K reputationPosted Jul 26, 2024, 9:39 AM EDT
Hi Abhishek,
do refer to my article.
https://www.c-sharpcorner.com/article/how-to-read-data-from-an-excel-sheet/