SQL Server stored procedure encountered ' table ' #TT ' no identity property cannot perform SET operation ' ERROR _mssql

Source: Internet
Author: User

Creates a temporary table that reports errors when inserting data into a temporary table.

A start prompt does not open the primary key, and then the primary key is turned on to prompt the above error exception.

Find information from the Internet did not find, and then to the group to ask you Daniel, a Daniel told me is not set the primary key.

I took a closer look at the hint and realized that I had set the primary key temporarily.

Code before the primary key:

CREATE TABLE #TT (
courseid int,
UserId int,
ClassId int
)
INSERT
into
#TT
(CourseID , UserId, ClassId)
SELECT 
CourseID,
UserId,
ClassId

Execution will report that the table ' #TT ' does not have an identity attribute. Unable to perform SET operation ' ERROR

After you modify the code:

CREATE TABLE #TT (
courseid int PRIMARY KEY,
UserId int,
ClassId int
)
INSERT
into #TT
(CourseID, UserId, ClassId)
SELECT 
CourseID,
UserId,
ClassId

No more errors.

Then I put primary key this keyword removed, SQL Server and no error. I don't know what's going on now!

Described above is a small set of SQL Server stored procedures introduced to the table #TT ' no identity property cannot perform SET operation ' ERROR, I hope to help you, if you have any questions please give me a message, small series will promptly reply to everyone. Here also thank you very much for the cloud Habitat Community website support!

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.