Batch insert of SQL statements

Source: Internet
Author: User
Batch insert data:
Define variables, execute the loop, and convert int to varchar. Example: Convert (varchar (10), @ BMC) Declare @ name varchar (50 );
Declare @ PWD varchar (10 );
Set @ Pwd = '000000 ';
Declare @ BMC int;
Set @ BMC = 101;
While (cast (@ BMC as INT) <120)
Begin
Set @ name = 'tv8' + convert (varchar (10), @ BMC );
Insert into DBO. t_topview_admin (f_psnid, f_status, f_bropwd, f_edittime, f_starttime, f_endtime, f_usertype) values ('tv8' + convert (varchar (10), @ BMC), 1, '123 ', getdate (), 20080320,20090319, 1)
Set @ BMC = @ BMC + 1
End

Batch insert data. This instance imports data from two tables with similar data structures to declare @ FID Int;
Set @ FID = 1;
While @ FID & lt; 100
Begin
Insert into partition (f_id, f_contentid, f_attachname, f_attachsize, f_attachaddress, f_edittime) Select top 1 f_id, f_mailid, f_attachname, f_attachsize, f_attachaddr, f_edittime from DBO. t_tlmail_attach where f_id> @ FID order by f_id ASC
Set @ FID = @ FID + 1
End

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.