Sometimes when you want to insert data into SQL database which is already in excel, inserting records one by one can be cumbersome.
This also applies when you want to update statements in SQL database which is in excel
Luckily you can generate SQL insert / update statements which you can later execute on the database console.
Below is the tutorial that will guide you to generate SQL statements in excel.
The example below shows a simple insert statement prepared from sales data in a table. But you can easily extend this method to prepare complex query statements depending on your data.
My data in excel is arranged like this
Important to note: The order and number of columns need to match your SQL data table
Once the data is ready it is very easy to generate the SQL queries using excel string addition operator – &.
The final prepared queries will look like:
You can now copy the query in your SQL database console
Formula: = “insert into customers values(‘” & A2 & “‘,'”&B2&”‘,'” &C2 &”‘,'” &D2 & “‘,'”&E2&”);”