SQL---Inserting multiple data at a time

Source: Internet
Author: User


--use when doing the test.
-Cons: The number of result sets is the same as the type.
INSERT into Student (StudentID, Studentname, Stduentage, Studentbirthday, Studentgender, Studentphone, Studentemail, Studentaddress, Student_courseid) SELECT StudentID, Studentname, Stduentage, Studentbirthday, Studentgender, Studentphone, Studentemail, studentaddress, Student_courseid from dbo. Student

Take a look at this sql:

INSERT into dbo. ClassSELECT'1102','Software 1102'UNION SELECT'1103','Software 1103'UNION SELECT'1104','Software 1104'UNION SELECT'1105','Software 1105'UNION SELECT'1106','Software 1106'UNION SELECT'1106','Software 1106'

Yellow sql: The result of the execution is:

(No column name) (No column name)
1102 Software 1102
1103 Software 1103
1104 Software 1104
1105 Software 1105
1106 Software 1106

We have learned the Union keyword and will automatically remove duplicate data. So only 5 data was queried.

Now fully execute the above sql:

See the number of rows affected: 5

SQL---Inserting multiple data at a time

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.