excel volume generated SQL statements

Source: https: //www.cnblogs.com/allen0118/p/3726455.html

We often encounter such a request: the user to send over some of the data to be stored in the database directly to us inside, some are Insert, Update, and so some small amount of data that we can take the most primitive way, that is, inside with SQL Insert into to achieve, but if there are dozens or even hundreds of thousands continue to write data when a single SQL statement, then it was tragic, but in fact there are two easy ways;

First, the Excel data collated after by SQL import feature lead directly into the database, but have to ensure a consistent database fields and Excel fields.

Second, to generate the corresponding by Excel SQL statement, simply copy the SQL statements can be executed inside the analyzer, the paper said about how to achieve this second approach.

First see the figure, our aim is to these 20 Insert data into the database inside, one of the two, then you can write your own Insert statement, there are 20 data, we can not completely handwritten 20 statement out of it,

Obviously, not one by one to write SQL, too much, there are only 20 here, if it is 200, 2000 data it?

INSERT INTO TableName(Column1,Column2,Column3) VALUES('Value1','Value2','Value3')

 

After a written statement, pulled directly from the beginning the end, you will find all of the script has a corresponding data, and this time you will be able to copy directly to the analyzer, press the "F5", OK, your job is done.

 Because the formula inside, so sometimes those statements will change, when you generate these statements, you can selectively pasted as value, and then put inside SQL to perform, as follows:

Guess you like

Origin www.cnblogs.com/tianyucheng/p/11246329.html