开发者

How can i solve "An explicit value for the identity column in table"?

if i try to add some data into my table error occurs:

Error:Msg 8101, Level 16, State 1, Line 1 An explicit value for the identity column in table 'ENG_PREP' can only be specified when a column list is used and IDENTITY_INSERT is ON.

insert into ENG_PREP VALUES('572012-01-1,572012-01-2,572012-01-3,572013-01-1,572013-01-2',
'',
'500',
'',
'A320 P.001-A',
'Removal of the LH Wing 开发者_如何学JAVASafety Rope',
'',
'',
'',
'0',
'',
'AF',
'12-00-00-081-001',
'',
'',
'',
'',
'',
'',
'' )


If you must write to the identity column, use

SET IDENTITY_INSERT YourTableName ON

just as the error message suggests.

Otherwise, don't try to write to the identity column.


Your statement

insert into ENG_PREP

will try to insert values into all of the columns of your table - including the IDENTITY column, where you should never insert a specific value.

What you need to do is specify which columns of your table you really want to insert values into, and leave out the IDENTITY column - that'll be automatically handled by SQL Server itself:

 INSERT INTO dbo.ENG_PREP(column1, column2, ...., columnX)
 VALUES(values1, values2, ...., valuesX)

You only need to specify those columns that you really want to set a value for (e.g. you can probably skip most of those columns where you just insert a '' in your example).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜