Using VS2005 today I needed to create a test database with a couple of
tables for a quick R&D test. Instead of opening up SQL Enterprise Tools, I
just used the VS2005 database tools and created a new table. I added an INT
column named ID and set it as the primary key. I saved the table. I then
went back into the designer and expanded the column Identity Specification
and tried to set the Identity property to Yes (true). It wouldn't let me.
I made sure Allow Nulls was NOT checked and tried again. Still no go.
Opened up help to:
ms-help://MS.VSCC.v80/MS.MSDN.v80/MS.VisualStudio.v80.en/dv_vdt01/html/d8949b19-3d8a-4b2a-a43c-6926c2aba64d.htm
"How to: Modify Column Identity Properties" and saw this note in the
documentation:
"The identity property can be set only for a column that disallows null
values and whose data type is decimal, int, numeric, smallint, bigint, or
tinyint. Also, it cannot be set for a primary key column."
Thinking I was going senile, I checked other tables I've created in the past
in my SQL instance and then resorted to looking up the Identity property in
the SQL Books Online and found *nothing* in there about not being able to
create a PK with an Ident property. I mean, I've done this same thing a
billion times in the past...that's the whole point of an identity property,
right?
So why won't the database designer in VS 2005 allow this simple action?
Regards,
todd
[MSFT] - 16 Nov 2005 09:03 GMT
Hello,
I tried your steps with a SQL server 2005 database instance, after create
such a table and save it, I can expand the Identity Specification and set
property "Is Identity" to true. Did you also connect to a SQL server 2005
database or others?
Luke
Todd Brooks - 17 Nov 2005 05:27 GMT
I connected to a SQL Server 2000 Standard Edition instance on the local
workstation.
todd
> Hello,
>
[quoted text clipped - 4 lines]
>
> Luke
[MSFT] - 18 Nov 2005 02:32 GMT
I also test with a SQL server 2000 database and got same result. So, my
question is, can you set the identity property when you create it in
designer or you just cannot change the identity property after you save
the whole table? Is your account a DBO on the database?
Luke