如何在 SQL Server 中创建 id 字段?

2021-09-18 00:00:00 sql-server visual-studio-2010

我想创建一个字段,该字段将自动填充并保持唯一性.

I want to make a field, which will be automatically filled, and stay unique.

更多说明:我有一个ID字段,应该由我的程序而不是用户填写,是我的主键.

More explanation: I have an ID field, which should be filled by my program not the user, and is my primary key.

如何在 SQL Server 中执行此操作?

How may I do it in SQL Server?

我使用的是 Visual Studio 2010

I'm using Visual Studio 2010

推荐答案

在您的 ID 列中,将身份"设置为是"并将种子"设置为 1.

On your ID column, set "identity" to yes and set the "seed" to 1.

享受吧!

相关文章