When you insert a temporary table for paging sorting, you can solve the problem of "adding an ID column. This table already has a column 'id' that inherits the identity attribute ".

Source: Internet
Author: User

Sorting page, SQL2000, encountered the following problems

Select Identity (INT, 1, 1) as PID, ID, username, classid into # collectioninfos from pk_collection

Select * from # collectioninfos

---

ID is the ID column of the original table, auto-increment.

The database reports the following error:

Server: Message 8108, level 16, status 1, Row 1
You cannot use the select into statement to add an ID column to the '# collectioninfos' table. The table already contains the 'id' column that inherits the identity attribute '.

All the solutions found on the Internet are to remove the logo column. How useful is the removal of the logo column.

Think about it and convert it as follows:

----
Select Identity (INT, 1, 1) as PID,Cast (ID as INT) as ID, Username, classid into # collectioninfos from pk_collectioninfo

Select * from # collectioninfos

Solve the problem.

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.