如何将值插入标识列..? [英] How to insert value into identity column..?
本文介绍了如何将值插入标识列..?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在一个标识列中插入一个值,但是我无法做到这一点。通常有助于将值插入到表的标识列中。
我的尝试:
set identity_insert meghr on
插入meghr选择'1'
设置identity_insert meghr off
错误如下图
消息8101,级别16,状态1,行2
表'meghr'中的标识列的显式值只能在列列表中指定使用并且IDENTITY_INSERT为ON。
Hi ,
I am inserting a value into identity column but am not able to do that..Kindly help to insert value into identity column of table..
What I have tried:
set identity_insert meghr on
insert into meghr select '1'
set identity_insert meghr off
error like in below
Msg 8101, Level 16, State 1, Line 2
An explicit value for the identity column in table 'meghr' can only be specified when a column list is used and IDENTITY_INSERT is ON.
推荐答案
您必须键入列名:
You have to type column name:
set identity_insert meghr on
insert into meghr (nos) VALUES (1)
set identity_insert meghr off
Identity列的含义是数据库设置值,而不是插入。如果你真的需要自己设置:
这个 [< a href =https://msdn.microsoft.com/en-us/library/ms188059.aspxtarget =_ blanktitle =新窗口> ^ ]会对你有帮助。
The meaning of an Identity column is that a database sets the value, not your insert. If you really need to set it yourself:
THIS[^] will help you.
如何插入值到SQL Server中的标识列 - SQLTeam.com [ ^ ]
https://msdn.microsoft.com/en-IN/library/ms188059.aspx?f=255&MSPPError = -2147217396 [ ^ ]
这篇关于如何将值插入标识列..?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文