About outputting multiple rows of data during SQL storage

Source: Internet
Author: User

DECLARE @num1 INT--The total number of rows that meet the criteria

Select @num1 =count (1) from Cardinfo where opendate between @date1 and @date2

[email protected] and @date2 for the start time to the end time, you can understand a condition

while (@num1 <>0)--the number of times a loop is formed with the following [email protected]=1
Begin
Print @num1-The value of the loop output @num1, minus one
Set @num1-=1
Select top 1 @uid = CardID from cardinfo where CardID [email protected] is the card number of the table, using pagination (1 pages per page)
Not in (select Top (@num1) CardID from Cardinfo) and--removes data from the previous (@num1-1) row

Opendate in (select Opendate from Cardinfo where opendate between @date1 and @date2)--where condition
Print @uid--loop out the desired data information
End

About outputting multiple rows of data during SQL storage

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.