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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using the Insert into statement

Status
Not open for further replies.

Kalisto

Programmer
Feb 18, 2003
997
GB
I am trying to run a simple insert into query, but keep hitting problems.

I dont want to go into it all at present, but if my table has an auto generated key, how do i insert into an existing table, as i need to supply all parameters when i insert, but the autonumber comes from the DB !

Can anyone who undesrstands me help (I know this must be a common answer with a simple solution)
 
You must list the columns to receive values and insert data only into those columns. It is possible to turn off the autonumber feature to allow inserting values. Normally this is part of an initial load or import process. The method depends on the brand of database you are using, it is not really a feature of SQL, so you need to post in the forum for your database, not in the ANSI SQL database.
 
ok, apologies.
using the insert into <table> syntax, what do i use, at present it's values (x) I have tried colums (x=y), and that doesnt work
 
Sorry, did not mean to be curt, only helpful. An example would be
Code:
INSERT Soldiers (name, rank, serial_number)
VALUES ('Bob','Private First Class', 987654321)
for a table that also has an autonumber column named soldier_id.
 
Thanks, np with ur answer, was mebbe not targetted enough

Thanks again,

K
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top