The SQL Server Stored Procedure encountered the error "Table'' # TT ''cannot perform the SET operation without the identity attribute,

Source: Internet
Author: User

The SQL Server Stored Procedure encountered the error "Table'' # TT ''cannot perform the SET operation without the identity attribute,

An error is reported when a temporary table is created and data is inserted into the temporary table.

The system prompts that the primary key is not opened at the beginning. When the primary key is opened, the system prompts that the above error is abnormal.

I couldn't find the information on the Internet, and then asked you about the information in the group. A Daniel told me that I didn't set the primary key.

I took a closer look at the prompt and suddenly realized that I set a primary key for the temporary.

Code before the primary key is absent:

Create table # TT (CourseId INT, UserId INT, ClassId INT) INSERTINTO # TT (CourseId, UserId, ClassId) SELECT CourseId, UserId, ClassIdFROM dbo. T_MyOrder

If executed, the "table '# tt' is not identified. Failed to perform the SET operation "error

Code after modification:

Create table # TT (CourseId int primary key, UserId INT, ClassId INT) INSERTINTO # TT (CourseId, UserId, ClassId) SELECT CourseId, UserId, ClassIdFROM dbo. T_MyOrder

No error is reported.

Then I removed the keyword 'Primary key', and SQL server does not report an error. I don't know what's going on now!

The above is a small series of SQL Server Stored Procedures encountered the "table" # TT "no identity attribute can not perform the SET operation" error, I hope to help you, if you have any questions, please leave a message and the editor will reply to you in time. Thank you very much for your support for the help House website!

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.