且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在Sql Server中将主键列设置为自动增量

更新时间:2022-10-20 17:32:44

您好,

您可以使用以下查询

例如



 创建  tbl_Emplooyee 
(Recordid bigint 主要 key identity


如果一次,则将列设置为主键意味着它充当自动增量栏...



身份是主键





http:/ /p2p.wrox.com/sql-server-2000/59608-how-can-i-alter-table-primary-key-identity.html [ ^ ]



http:// ***.co m / questions / 11897007 / alter-table-column-for-primary-key-and-identity [ ^ ]



 column_name  bigint   primary   key  身份 





嘿..不要担心开心


1。首先将列设置为主列。

2.将该列的dataType设置为Int。

3.转到列属性并将标识规范设置为是和身份增量到1


I want to know How to alter a Primary Key column to Auto-Increment, also it should work as Both Primary Key and auto increment field... So that the Entries can have Unique 'ID'(Primary Key Column Name)...

Hi,
You can use below query
e.g.

Create table tbl_Emplooyee
(Recordid bigint Primary key identity)


If once, you set a column as Primary Key Means it act as auto increment column...

Identity is the main key


http://p2p.wrox.com/sql-server-2000/59608-how-can-i-alter-table-primary-key-identity.html[^]

http://***.com/questions/11897007/alter-table-column-for-primary-key-and-identity[^]

column_name bigint primary key identity



hey..dont worry be happy


1. First set the column as primary.
2. Set the dataType of that column as Int.
3. Go to column Property and set Identity Specification 'Yes' and Identity Increment to 1