开发者

Not able to set is Identity key as Yes in SQL Server

开发者 https://www.devze.com 2023-02-20 20:30 出处:网络
I just not created a new database with 2 tables in it. In a table, I have set a column as a primary key and trying to change its properties i.e. s开发者_如何学运维etting is Identity to YES, but am not

I just not created a new database with 2 tables in it. In a table, I have set a column as a primary key and trying to change its properties i.e. s开发者_如何学运维etting is Identity to YES, but am not able to do so.

Any ideas/suggestions?


Make sure the datatype is int and not something else.

You can't have an identity on a different type.


Do you have data in the table? You can't make an IDENTITY column if you do.


Did you expand that option? As I recall, the identity spec is actually grayed out and not alterable until you expand its little sub-tree. Then in there you can actually just double click on IsIdentity and you should be all set

Made it an answer so I could put an image. Let us know if this isn't the problem.

Not able to set is Identity key as Yes in SQL Server


The (Is Identity) field will also be greyed out if there is a Default Value or Binding set on the column.


IDENTITY

If you want to retain the data for that particular column. you can use this method. New table creation with identity.

CREATE TABLE dbo.TableName

(ID INT NOT NULL IDENTITY (1, 1),

EMPNAME varchar (25),

AGE INT

PRIMARY KEY(ID));

Made By : Syed Baqar Hassan

http://i.stack.imgur.com/sEbxQ.png

0

精彩评论

暂无评论...
验证码 换一张
取 消