Insert 2000 data records cyclically in SQL Server 1 million (original)

Source: Internet
Author: User

Some time ago, when testing more than 1 million data records, we needed to insert 1 million records into the database. At that time, I used C # To insert records. Later, we found that, in fact, you can also use SQL to implement it, and it is simpler! The following is an example I wrote. It is very simple and you should be able to understand it.

Declare @ I int -- variable @ I
Set @ I = 1 -- initialize @ I to 1
While @ I <100 -- If @ I is less than 100, change to 1 million here to insert 1 million records
Begin ------------------
Insert into Manager (username, userpwd) values ('kgdids', '123 ')
Set @ I = @ I + 1
End --------------------

it's easy. In fact, SQL is also very powerful, and many things can be done by themselves. in the past, I put a lot of things in the Program . Now I am used to the SQL, because it can be easily modified.

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.