SQL generates 1000 million data and SQL generates million data

Source: Internet
Author: User
Tags rowcount

SQL generates 1000 million data and SQL generates million data

Declare @ d datetimeset @ d = getdate () select * from dbo. chunkSegmentMappingselect [statement execution time (MS)] = datediff (MS, @ d, getdate () USE tempdbGOCREATE TABLE tb (id char (8 )) create unique index IX_tb ON tb (id) WITH IGNORE_DUP_KEY -- ignore duplicate record index godeclare @ dt datetimeSET @ dt = GETDATE () set nocount offdeclare @ row intSET @ row = 1000000 -- the total number of records is WWHILE @ row> 0 begin raiserror ('need % d rows ', 10, 1, @ row) with nowait set rowcount @ row INSERT tb SELECT id = RIGHT (100000000 + CONVERT (bigint, ABS (CHECKSUM (NEWID (), 8) -- FROM syscolumns c1, syscolumns c2 -- set nocount on 49 Second FROM syscolumns c1, sysobjects o -- set nocount on 47 Second SET @ row = @ row-@ ROWCOUNT -- SET the number of records to be inserted in the next loop ENDSELECT BeginDate = @ dt, EndDate = GETDATE (), second = DATEDIFF (Second, @ dt, GETDATE () goselect count (*) FROM tbGOSELECT * FROM tbDROP TABLE tb

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.