Insert column via SQL, HOW?

octick

New member
Local time
Today, 06:02
Joined
Oct 29, 2004
Messages
7
I have a table ([Data]) that I have made. I need to insert a Autonumber column ([Rank]) into the table and keep it automated. I am looking for a SQL statement that will insert the Column [Rank] into table [Data] as an Autonumber starting at 1 everytime.

I tried following instuctions on how to reset the autonumber column back to "1" but it didn't ever work.

I appended into the blank table making the Autonumber field = 0 (1 lower than what I need) from a duplicate table with the field changed to a Number field, deleted it out of the table than appended the real data into it. Starts right back where I left off.

I just need a quick query to add the Autonumber column everytime I remake the table.

Thanks ahead of time.
Aron
 
Sorry, don't have time right now to get into this, but here is sample code that will create a table with an auto_increment field, and it should start at 0.

CREATE TABLE Friends
([FriendID] COUNTER NOT NULL PRIMARY KEY,
[LastName] text,
[FirstName] text,
[Birthdate] date,
[Phone] text,
[Notes] memo);

HTH :cool:
 
If all you want to do is add counter to an existing table then use this sql. If you try to run when the field already exisis, you'll get an error.



ALTER TABLE Data
ADD COLUMN NewField Counter
 
gem1204 said:
If all you want to do is add counter to an existing table then use this sql. If you try to run when the field already exisis, you'll get an error.



ALTER TABLE Data
ADD COLUMN NewField Counter


That worked.
ALTER TABLE [Data]
ADD COLUMN Rank Counter

Thanks...I have been battling with this for over 3 weeks.
Makes my life a whole lot easier.
 

Users who are viewing this thread

Back
Top Bottom