[thelist] returning the row id after an insert (MS SQL 7)

Chris Blessing webguy at mail.rit.edu
Thu Dec 6 12:09:39 CST 2001


Rudy, thanks for the info.  I was unaware that this was about as efficient
as it gets, so I guess I'll just leave it as is. =)

Thanks again.

Chris Blessing
webguy at mail.rit.edu
http://www.330i.net

> -----Original Message-----
> From: thelist-admin at lists.evolt.org
> [mailto:thelist-admin at lists.evolt.org]On Behalf Of rudy
> Sent: Thursday, December 06, 2001 12:13 PM
> To: thelist at lists.evolt.org
> Subject: Re: [thelist] returning the row id after an insert (MS SQL 7)
>
>
> >What I'm doing now is inserting new rows into my table and then selecting
> >the row id with a separate sql statement based on the data
> inserted in the
> >prior sql statement.  Isn't there a way to do this in one
> statement rather
> >than 2?  Any help is much appreciated.
>
> hi chris
>
> at least you are doing the second query based on the *data* of the insert,
> rather than using "select max(pkey)"
>
>   see http://lists.evolt.org/archive/Week-of-Mon-20010806/010771.html
>
> querying back using data is actually a pretty decent way of doing it,
> because it's compatible with multithreading, and does not require you to
> set the two statements into a transaction block
>
> see also http://lists.evolt.org/archive/Week-of-Mon-20010910/013174.html
>
> anyhow, since you are using sql/server, you should look into @@identity
>
> rudy
>
>
> ---------------------------------------
> For unsubscribe and other options, including
> the Tip Harvester and archive of TheList go to:
> http://lists.evolt.org Workers of the Web, evolt !





More information about the thelist mailing list