Hi Dave,

I found it easier generating the primary keys at the frontend rather 
than asking the backend to generate it (autoinc or @@)

I use the technique suggested in
"FoxPro 2.5 Advanced Developer's Handbook"
*by Adams and Powell, Chapter 18, page 644.
FUNCTION ukey
PARAMETER lenkey
LOCAL len1,len2,key1,key2
IF PARAMETERS()=0
     lenkey=8
ENDIF
len1=FLOOR(lenkey/2)
len2=lenkey-len1
key1= RIGHT(SYS(3),len1)
key2= RIGHT(SYS(2015),len2)
RETURN key1+key2

This logic should be ok for small databases. But may not be sufficent 
for really huge ones. Maybe adding a GUID with the above logic for a 
"more" unique primary key.

Sincerely,

_Ajit Abraham

Dave Crozier wrote:
> 
> When adding a record into the client/server table the SQL Server
> automatically generates the identity (Primary Key) at the back end and then
> you use (in M$SQL anyway) the "select @@Identity" command to retrieve back
> the new Server PK into VFP if you require it for further processing, the PK
> in the VFP cursor will be 0 however and this is the problem. 



__________________________________________________
D O T E A S Y - "Join the web hosting revolution!"
             http://www.doteasy.com


_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/profox
OT-free version of this list: http://leafe.com/mailman/listinfo/profoxtech
Searchable Archive: http://leafe.com/archives/search/profox
This message: http://leafe.com/archives/byMID/profox/[EMAIL PROTECTED]
** All postings, unless explicitly stated otherwise, are the opinions of the 
author, and do not constitute legal or medical advice. This statement is added 
to the messages for those lawyers who are too stupid to see the obvious.

Reply via email to