At 04:22 PM 5/24/2000 -0400, you wrote:
>------------------------------
>
>Date: Wed, 24 May 2000 13:14:07 -0400
>From: [EMAIL PROTECTED] (Dave Watts)
>To: <[EMAIL PROTECTED]>
>Cc: <[EMAIL PROTECTED]>
>Subject: RE: Avoiding using the MAX function
>Message-ID: <001201bfc5a3$d5ffb770$[EMAIL PROTECTED]>
>
><< snip >>
>...
> > The database in question is a SQL Server database. (Although
> > it would be good to know how to do it with MS Access if its
> > possible).
>
>You can either use stored procedures to perform inserts and retrieve
>identity values, or attach insert triggers to your table. Here's an example
>of an insert stored procedure:
>
>CREATE PROC insItem
>
>@Item_Name varchar(30),
>@Item_Desc varchar(255)
>
>AS
>
>INSERT INTO Item
>                 (Item_Name,
>                 Item_Desc)
>VALUES
>                 (@Item_Name,
>                 @Item_Desc)
>SELECT ID = @@IDENTITY
>
>You could then reference the ID field in the resulting recordset.

I use a variation on this idea.  But instead of just selecting the id I do 
the following:

SELECT item_id, item_name, item_desc
         FROM item
         WHERE item_id = @@IDENTITY

This way I get a recordset back of "exactly" what I inserted plus the new 
ID field.

><<snip>>
>
>Dave Watts, CTO, Fig Leaf Software
>http://www.figleaf.com/
>voice: (202) 797-5496
>fax: (202) 797-5444


Bill Grover
Supervisor, IS
EU Services, Inc.
649 N Horners Ln
Rockville MD 20850

Phone:  301-424-3300 x396
FAX:    301-424-3300 x1396#
E-Mail: [EMAIL PROTECTED]

------------------------------------------------------------------------------
Archives: http://www.eGroups.com/list/cf-talk
To Unsubscribe visit 
http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/cf_talk or send a 
message to [EMAIL PROTECTED] with 'unsubscribe' in the body.

Reply via email to