无法在DB中插入实体 [英] Cannot insert with entity in DB
本文介绍了无法在DB中插入实体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Cannot insert explicit value for identity column in table 'PageGroups' when IDENTITY_INSERT is set to OFF.
什么是这个吗?
大喊大叫删除[/编辑]
What is this?
Shouting removed[/Edit]
推荐答案
你可以插入显式值用于SQL中的标识列
为
1.首先为表设置IDENTITY_INSERT ON
2.通过指定列名来插入vlues注意你必须指定列名。
3. se t IDENTITY_INSERT关闭表
SET IDENTITY_INSERT TableName ON
INSERT INTO TableName
(ID,
名称,
年龄)
VALUES (20,
& amp;#39; Pankaj& amp;#39;,
24)
SET IDENTITY_INSERT TableName OFF
You can insert explicit value for identity column in SQL
as
1. First set IDENTITY_INSERT ON for Table
2. Insert the vlues by specifying column name note that you must have to specify the column name .
3. set IDENTITY_INSERT OFF for Table
SET IDENTITY_INSERT TableName ON
INSERT INTO TableName
(ID,
Name,
Age)
VALUES (20,
'Pankaj',
24)
SET IDENTITY_INSERT TableName OFF
这篇关于无法在DB中插入实体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文