Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Queries / March 2008

Tip: Looking for answers? Try searching our database.

Primary Key AutoNumber Field

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
a - 13 Mar 2008 05:51 GMT
How can I create Primary Key autonumber field by SQL Command?
For existing data start from 1 and end at the end of rows
Example:
Field Name : Id Auto Number (Primary Key)
Id    Name
1    a
2    b
3    c
and so on
thank you
MGFoster - 13 Mar 2008 07:44 GMT
> How can I create Primary Key autonumber field by SQL Command?
> For existing data start from 1 and end at the end of rows
[quoted text clipped - 6 lines]
> and so on
> thank you

If you have an existing table (TableA), like this:

ALTER TABLE TableA ADD COLUMN Id COUNTER PRIMARY KEY;

If you don't have the table, like this:

CREATE TABLE TableA (
  Id COUNTER PRIMARY KEY,
  Name, Text(1) NOT NULL
);

In the JET db (Access) the "Counter" data type is the AutoNumber data
type.  If you are using SQL Server as your back-end, substitute
IDENTITY(1,1) for COUNTER.

You can run both DDL statements from the SQL view of a QueryDef.

Signature

MGFoster:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)
** Respond only to this newsgroup.  I DO NOT respond to emails **

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.