Add an AutoNumber column as primary key field in Access (2003/7) through DDL


Here is the syntax:

Alter TABLE XYZ
Add column myID  COUNTER CONSTRAINT PrimaryKey PRIMARY KEY 

If we want to set the seed for the AutoNumber field, we can run this query:
alter table XYZ
alter column myID Counter(1000,1);

 

There is a documnet from Microsoft to demostrate:

How to Create and Drop Tables and Relationships Using SQL DDL

refer to this link: http://support.microsoft.com/?id=116145

You can also find more information on this topic from this document:

(How to use common Data Definition Language (DDL) SQL statements for the Jet database engine)

http://support.microsoft.com/default.aspx?scid=kb;en-us;180841

 

 

Advertisements


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s