Teach you how to use Excel to generate SQL statements in batches and process a large amount of data.

Source: Internet
Author: User

Teach you how to use Excel to generate SQL statements in batches and process a large amount of data.

During system or project creation, we often encounter the following requirement: the user sends us some data and requires us to import the data to the data

In the data library, for a small amount of data, the most primitive method can be used to solve the problem, directly using statements in SQL, but if there are thousands

What about data? If you continue to write SQL statements separately, it is estimated that you will be impulsive to write dozens of lines. There are actually two simple methods:

1. Sort the Excel Data and import the data directly to the database through the SQL import function. However, ensure that the fields in the database are consistent with those in Excel.

2. Use Excel to generate the corresponding SQL statement and place it in the new SQL query for execution. The following describes how to use this method:

We want to import the following 20 pieces of data into the database. One Insert is too slow. We are a lazy person. To be lazy, we can only think of other methods.


In cells E1 of Excel, write an SQL statement. You only need to write this statement:

Insert into TableName (Column1, Column2, Column3) VALUES ('value1 ', 'value2', 'value3 ')


Then, pull it from the beginning to the end, and you will find that all the data has the corresponding script, and then copy the relevant SQL statements directly to the analyzer, F5, OK, and the task is completed!

I would like to share with you a little bit of experience. This is an era of sharing, sharing, helping, and improving.


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.