How do I use autoincrement on the primary key in a table in sdf file

T

Tony Johansson

Hello!

I have a sdf file that contains some tables and in one table I want to use
autoincrement on the primary key but I haven't
find any way to do it despite googling for it.

If I open the Server Explorer in VS 2008 I can see the sdf file. If I now
click on the Tables under the sdf file I can see all the tables that I have
in the sdf file. I want the table Purchase to use auto increment so I right
click on table Purchase and choose
Edit Table Schema.When this dialog open I can see fields like
Identity,IdentityIncrement,IdentitySeed but alll of these are greyout so I
can use any of them.

Does anyone have any idea how I use auto increment on sdf file ?

//Tony
 
A

andy

Hello!

I have a sdf file that contains some tables and in one table I want to use
autoincrement on the primary key but I haven't
find any way to do it despite googling for it.

If I open the Server Explorer in VS 2008 I can see the sdf file. If I now
click on the Tables under the sdf file I can see all the tables that I have
in the sdf file. I want the table Purchase to use auto increment so I right
click on table Purchase and choose
Edit Table Schema.When this dialog open I can see fields like
Identity,IdentityIncrement,IdentitySeed but alll of these are greyout so I
can use any of them.

Does anyone have any idea how I use auto increment on sdf file ?

//Tony

This is a sql ce database?

You can't do that from VS2008 on an existing table.
You can only add an identity column as you create the table.
Alter table errors, adding a column and setting it to identity errors
when you save,
Simplest approach is to script the table, alter the create script,
drop the table and re-create.

Saving data elsewhere might be advisable prior to all this.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top