使用Visual C#2008 Express和SQL Server 2008 Express,我想将新记录插入数据库AdventureWorks,表格Person.Contact。 到我的令人惊讶的是,这个表的'int-value identity列" ContactID"似乎不是自动增量。我不知道如何确认这是如此。 (我已经安装了SQL Server Management Studio,如果有帮助的话。) 如何确认这一点,以及如何使ContactID自动增加? 顺便提一下,自动递增会从最高的现有ContactID开始递增,还是会先使用表中不存在的较小的ContactID值(可能是由于删除)?
Using Visual C# 2008 Express and SQL Server 2008 Express, I would like to insert new records into database "AdventureWorks", table "Person.Contact". To my surprise, this table''s int-value identity column "ContactID" does not appear to be auto-increment. I don''t know how to confirm for sure that this is so. (I have installed SQL Server Management Studio, if that helps.) How can I confirm this, and how can I make ContactID auto-increment? And incidentally, will auto-increment just start incrementing from the highest existing ContactID, or will it first use lesser ContactID values that are absent from the table (presumably due to deletions)?
推荐答案打开Management Studio。右键单击表格,然后选择修改。在身份规范上,检查属性是否设置为YES。 - CK Open the Management Studio. Right click on the table then choose modify. On the Identity Specification, check if the property is set to YES. -- CK
ck9663: 在SQL Server 2008 Management Studio Express中,只有三个选项出现在身份规范下(身份),身份增量和身份种子,分别设置为是,1和1。身份增量= 1似乎意味着自动增量已开启,但它似乎无法正常工作。 但也许我只是不知道我是什么我在做。我按如下方式创建新的DataRow: ck9663: In SQL Server 2008 Management Studio Express, only three options appear under Identity Specification: (Is Identity), Identity Increment and Identity Seed, which are set to Yes, 1 and 1, respectively. Identity Increment = 1 would seem to imply that auto-increment is on, but it doesn''t seem to be working. But maybe I just don''t know what I''m doing. I create the new DataRow as follows: 展开 | 选择 | Wrap | 行号
尝试对表本身进行插入。或许它是一个示例数据库,所以微软只允许只读。 - CK Try to do an insert on the table itself. Or maybe that it''s a sample DB so microsoft only allow read-only. -- CK
更多推荐
自动增量标识列
发布评论