riverguy, without getting into a big discussion, which you might not want, i wasn't suggesting
another unique key, i was suggesting that the table should already have one (besides the autonumber, of course)
and yes, i am aware of the sales transaction problem ;-)
do a google for
"three cans of cat food" +sql
some would argue that you don't really have a relational table if it doesn't have a candidate key, but if this is the issue, i think i'm on the side of the database practitioners (who say that yes of course you can have a table without a unique key) rather than the relational theorists (who say that every relation must have a candidate key)
so in the case of the cat food, yes, you'd better declare some kind of surrogate primary key
so i guess the "read the row back using the candidate key values" won't work for the cat food, and i stand corrected
(but aren't cat-food-type sales transaction records typically loaded in bulk, not inserted and queried one at a time? and let's not forget the main reason for wanting to know the autonumber key value -- which is to use as a foreign key value in some related table, which is unlikely for individual rows of cat food)
about @@identity, yes, i know about scope_identity, it just slipped by mind (again)
rudy |
r937.com |
Ask the Expert |
Premium SQL Articles
SQL for Database-Driven Web Sites (next course starts March 6 2005)