You cannot use the select into statement to add an ID column to the '# tb' table. The table already contains the 'id' column that inherits the ID attribute'

Source: Internet
Author: User

SQL Server has a strange problem (2000/2005 all have this problem ):

The mm_bjjhmx table has the ID of the auto-increment column of the primary key, and a column "sequence number" is also required ".

Run the following statements:

Select Identity (INT, 1, 1) XH, A. * into # TB
From mm_bjjhmx
Where bjjhid = 4
Order by A. bjbm, A. bjmc;
Select * from # TB
Drop table # TB;

Always error:

Message 8108, level 16, state 1, 1st rows
You cannot use the select into statement to add an ID column to the '# tb' table. The table already contains the 'id' column that inherits the ID attribute '.

However, the following statements are normal:

Select Identity (INT, 1, 1) XH, A. * into # TB
From mm_bjjhmx a left join mm_bj on mm_bj.id = A. bjid
Where bjjhid = 4
Order by A. bjbm, A. bjmc;
Select * from # TB
Drop table # TB;

That is, if multiple tables are associated, the columns displayed are the same, but the former cannot be used, and the latter is normal. It's strange that some people who know it can help explain it, but it is also a solution.

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.