> scope_identity and @@identity are one type of solution. Primary Keys that > are autoincremented are hard to follow soemtimes and are a bit tricky to > retrieve sometimes on high transactional systems.
Which is exactly why I prefer Oracle's (and PostgreSQL as well, incidentally) method - you grab a value from the sequence first, and then apply it as your PK, FK's, in the subsequent insert(s). > An easier way would be > just create a GUID or UUID that would gurantee uniqueness that is not > incremented. A very good suggestion, particularly if database portability is the goal. Since virtually every DBMS uses a slightly different method for generating unique key values, this is really the only practical way to achieve real portability. > I typically don't make my UUIDs my primary keys are I prefer database to > perform binary searchings on numbers and 35 character strings. I do > advocate that you put a non-clustered index on the column for easier > retrieval as if to treat it like a foreign key. And that's sort of the rub - UUIDs have some drawbacks as you describe. Also, in a case where a PK value may end up as a URL query string, your URLs start getting rather long and unfriendly if you use UUID. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Introducing the Fusion Authority Quarterly Update. 80 pages of hard-hitting, up-to-date ColdFusion information by your peers, delivered to your door four times a year. http://www.fusionauthority.com/quarterly Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:255793 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4

