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.
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
精彩评论