Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to solve the SQLServer IDENTITY_INSERT problem

2025-03-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly introduces "how to solve the SQLServer IDENTITY_INSERT problem". In the daily operation, I believe that many people have doubts about how to solve the SQLServer IDENTITY_INSERT problem. The editor consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful for you to answer the doubts about "how to solve the SQLServer IDENTITY_INSERT problem"! Next, please follow the editor to study!

Question:

Columns with self-increasing attributes cannot perform insert into operations directly

Create table chenjch_tbs01 (id int IDENTITY (1) NOT NULL,age int)

Insert into chenjch_tbs01 values (1 dint 1)

Message 8101, level 16, status 1, line 1

Explicit values can be specified for identity columns in table 'chenjch_tbs01' only if column lists are used and IDENTITY_INSERT is ON.

Insert into chenjch_tbs01 (id,age) values (1BI 1)

Message 544, level 16, status 1, line 1

When IDENTITY_INSERT is set to OFF, explicit values cannot be inserted for the identity column in the table 'chenjch_tbs01'.

Resolve:

SET IDENTITY_INSERT chenjch_tbs01 ON

-select * from sys.objects where type='U' and name='chenjch_tbs01';-object_id=980406762

-- select column_id,name from sys.columns where object_id=980406762 order by column_id

Insert into chenjch_tbs01 (id,age) values (1BI 1)

At this point, the study on "how to solve the SQLServer IDENTITY_INSERT problem" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report