Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Add Autonumber to a table! 1

Status
Not open for further replies.

JojoKa

Technical User
Mar 28, 2006
18
US
Hi,
How can add an autonumber to an existiing table? Thanks so much in advance
Joseph
 
something like this ?
ALTER TABLE myTable ADD COLUMN myID COUNTER(1,1) CONSTRAINT PrimaryKey PRIMARY KEY;

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Worked. Thank you very much for your quick answer.

Joseph
 
Hi,

I get Run-time error '3090'

I've tried it a variety of ways. I may be missing a Reference for the "COUNTER ...." part of the code as I can add other fields this way.

Any suggestions are appreciated.

Thanks in advance,
Paolo
 
No table may have more than ONE AutoNumber field ...

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Hi PHV,

Interesting point and exactly what happened. Does this mean you can only have one?

Thanks,
Paolo
 
Why would you want more than one autonumber field per table ?
 
HI PHV,

I don't. I was just checking, for the future really.

I blew my brains out yesterday trying to use SQL to add a whole bunch of records to a table that had a PrimaryKey. After many hours of failling to attempt to rework the SQL code, I lucked upon a Microsoft MSDN website link informing me that this can't be done.

I take it that neither of these can be done?

Thanks,
Paolo
 
I take it that neither of these can be done?
neither of WHAT ?
 
Hi PHV

1. I take it that more than one AutoNumber field is not possible, at least through SQL.

2. I take it that many records cannot be added to a table with a PrimaryKey using SQL and the records must be looped into the table.

Thanks,
Paolo
 
1. True (SQL or not doesn't matter)
2. False
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top