visual-studio-2010 - 如何在内置于 sql server 的 Visual Studio 中自动增加主键?

标签 visual-studio-2010 sql-server-express auto-increment

我使用的是 Visual Studio 2010 premium,并使用 Visual Studio 数据库工具创建了一个数据库。我将一个字段设置为主键,我想让它自动递增。

但是当我查看属性时,它并不活跃。我的意思是我无法使用 Visual Studio 2010 Premium 内置数据库工具进行设置。我无法设置身份规范。是因为我使用的是 Visual Studio 2010 高级版吗?如何使 productID 列自动递增?

enter image description here

最佳答案

将其数据类型更改为 int (或类似)。您不能设置 IDENTITY nchar(10) 上的规范柱子。
来自 CREATE TABLE :

IDENTITY

Indicates that the new column is an identity column. When a new row is added to the table, the Database Engine provides a unique, incremental value for the column. Identity columns are typically used with PRIMARY KEY constraints to serve as the unique row identifier for the table. The IDENTITY property can be assigned to tinyint, smallint, int, bigint, decimal(p,0), or numeric(p,0) columns. Only one identity column can be created per table. Bound defaults and DEFAULT constraints cannot be used with an identity column. Both the seed and increment or neither must be specified. If neither is specified, the default is (1,1).


(我的 重点 )

关于visual-studio-2010 - 如何在内置于 sql server 的 Visual Studio 中自动增加主键?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16434333/

相关文章:

visual-studio-2010 - Visual Studio HTM 编辑器包未正确加载

sql-server - 从SSMS连接到在容器内运行的SQL Server Express

delphi - 如何从 SQL Express 2012 获取数据更改通知?

sql-server - 主机文件中的 SQL 服务器名称

php - 使用 angularjs php 和 mysql 字母数字自动递增 id

MySQL:忘记设置自动增量

mysql - 首先对行进行排序,然后在 MySQL 中添加临时自增列

c# - 如何让项目在事件的 Visual Studio 配置中构建?

vb.net - VS 2010 中缺少命名空间

.net - 如何使 MSBuild 在引用的项目中正确跟踪使用外部工具生成的文件?