Methods for selecting M-N entries

Source: Internet
Author: User

1. If there are no other identity columns in tablename, then:
Select Identity (INT) id0, * into # temp from tablename

N to M statements:
Select * from # temp where id0> = N and id0 <= m

If you report an error when executing the Select Identity (INT) id0, * into # temp from tablename statement, this is because the select into/bulkcopy attribute in the middle of your DB is not enabled and must be executed first:
Exec sp_dboption your DB name, 'select into/bulkcopy', true

2. If the table contains the identity attribute, it is simple:
Select * From tablename where identitycol between N and m

Of course there will be some other simpler methods... Haha

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.