大家好, 能否请您点击下面的错误? 只有在使用列列表并且IDENTITY_INSERT为ON时才能指定表''tblreg''中标识列的显式值。 感谢您的帮助。
解决方案如果您将列声明为 Identity = true ,然后SQL将处理值并将按顺序分配它们,以便您不能重复。如果您在任何时候尝试通过INSERT或UPDATE操作设置该字段的值,SQL将抛出该异常。 最常见的错误是尝试和执行匿名INSERT操作: INSERT INTO MyTable VALUES( 1 , 2 , 3 )
表中的第一列是ID列,声明为identity。 SQL尝试以数字列顺序分配此类插入,因此尝试将第一个值写入Identity字段。使用时始终列出列,并且您不会遇到问题:
INSERT INTO MyTable(ProdCount,ItemNo,Bananas) VALUES ( 1 , 2 , 3 )
它表示你试图在一个声明为 Identity colunm的colunm中插入一个值。 看看下面的链接以了解身份。 en.wikipedia/ wiki / Identity_column http:/ /www.sqlteam/article/understanding-identity-columns 解决方案: - 要么不指定值您声明为Identity的colunm的Insert语句colunm。或者,如果您想继续使用显式值,请查看以下链接以解决您的问题。 blog.sqlauthority/2007/03/28/sql-server-fix-error-8101-an-explicit-value-for-the-identity-column-in -table-可以仅待指定-时-A-柱一览被使用的和 - IDENTITY_INSERT-是开/
Hi Everyone, Can you please with the error below? An explicit value for the identity column in table ''tblreg'' can only be specified when a column list is used and IDENTITY_INSERT is ON. Thanks for your help.
解决方案 If you declare a column as Identity = true, then SQL will handle the values and will assign them sequentially so that you cannot get repeats. If you try at any time to set the value of that field via an INSERT or UPDATE operation, SQL will throw that exception. The most common mistake is to try and do an "anonymous" INSERT operation: INSERT INTO MyTable VALUES (1, 2, 3)Where the first column in the table is the ID column, declared as identity. SQL tries to assign such inserts in numerical column order, and so tries to write the first value into the Identity field. USe names columns at all times and you won''t get the problem:
INSERT INTO MyTable (ProdCount, ItemNo, Bananas) VALUES (1, 2, 3)Its indicating you are trying to insert a value in a colunm which is declared as an Identity colunm. Have a look at below link to understand Identity. en.wikipedia/wiki/Identity_column www.sqlteam/article/understanding-identity-columns Solution :- Either do not specify value in your Insert statement for the colunm which is declared as an Identity colunm. Or incase if you want to continue with explicit value then have a look at below link to resolve your issue. blog.sqlauthority/2007/03/28/sql-server-fix-error-8101-an-explicit-value-for-the-identity-column-in-table-can-only-be-specified-when-a-column-list-is-used-and-identity_insert-is-on/更多推荐
标识列的显式值
发布评论