Generate SQL statements for Excel Data

Source: Internet
Author: User

In practical applications, we often need to import data in Excel into databases such as ms SQL Server or MySQL oracle. These databases provide good tools for users to directly import data in Excel into the database.

Fx6 \ HS) ik C. ug0YoushangCommunityD * Q} 3N U: W "GBJ

However, in many cases, we cannot directly operate databases.Management(Because the security needs to configure the firewall to intercept the database port), we can only remotely operate the database through the web page. In this case, convert the data in Excel to SQLInsert statementIt is very necessary.Youshang community n) J' @ "ei8 _ p

Youshang community b2p u! J? QF

Example:

Jc3tm7ef (B0

? 5_@ 3ksp 'J] 9m0The Excel table contains three columns of data: A, B, and C. You want to import the data to the database users table. The corresponding fields are name, sex, and age.

-K @ A * MCB @ 9e0Youshang community re ^ yd5b y'e; I [* z3t

Add a column to your Excel table and use the Excel Formula to automatically generate SQL statements. The method is as follows:

R4m} 0 \ _ te-| 6 h @ 0

@ Qk9dm3h01. Add a column (column D)Youshang community 5R (nw0h * nwomdk ^

Youshang community Z % L} $ Y & n1h \ f

2. In column D of the first row, enter the formula = concatenate ("insert into users (name, sex, age) values ('", A1 ,"', '", B1,"', '", C1 ,"');")Youshang community f z d; AQ _-c {] S

6] | & J fd4gis03. At this time, D1 has generated the following SQL statement: insert into users (name, sex, age) values ('Ls', 'female, '24 ');Youshang community JCA | oi3cb2t

Youshang community e9o 'ui. l, oh "V

4. Copy the D1 formula to column D of all rowsYoushang community lk1zqe $ ~ G J

3d & Q | kV; bd05. All SQL statements have been generated in column D.

8u5r /~ Gzj & j3P-p0WMB * C V' K/j9a?

6. Copy column D to a plain text file.

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.