That's just what I needed. Thaks very much.
> If you are using SQL Server this fairly easy to do. Simply roll the whole
> lot into one stored proc. The stored proc would look something like this:
>
> CREATE PROCEDURE execInsertPeople
> @Fname Varchar(50), @LName Varchar(50), @Email Varchar(75), @City
> Varchar(30)
> AS
>
> DECLARE @City Int
>
> INSERT INTO tblCity
> (txtCity)
> VALUES
> (@City)
> SET @City = @@IDENTITY
>
> INSERT INTO tblPerson
> (txtFName, txtLName, txtEmail, intCityID)
> VALUES
> (@FName, @LName, @Email, @City)
>
> The @@IDENTITY variable stores the last identity stored in the database.
You
> will need to expand this to include the countries and zip codes. They
need
> to be inserted before the data goes into tblPerson so that you can get
the
> IDs
>
> -----Original Message-----
> From: Hugh Anderson [mailto:webmaster@u...]
> Sent: Tuesday, 15 May 2001 5:48 AM
> To: sql language
> Subject: [sql_language] RE: Novice Question Re Inserting Into Related
> Tabl- es
>
>
> Thanks. I have foreign keys in the main table corresponding to a primary
> key ID in each of the separate (lookup?) tables. When I do an INSERT the
> primary key IDs (identity) columns get entered properly, but how do the
> corresponding keys get entered in the main table? I know I'm missing
> something quite simple but ...
>