As a character field. I think I got this code from Rick Strahl's website a few years ago....
DECLARE INTEGER CoCreateGuid ;
IN Ole32.dll ;
STRING @lcGUIDStruc
DECLARE INTEGER StringFromGUID2 ;
IN Ole32.dll ;
STRING cGUIDStruc, ;
STRING @cGUID, ;
LONG nSize
PROCEDURE GetGUID
cStrucGUID=SPACE(16)
cGUID=SPACE(80)
nSize=40
IF CoCreateGuid(@cStrucGUID) # 0
RETURN ""
ENDIF
IF StringFromGUID2(cStrucGUID,@cGuid,nSize) = 0
RETURN ""
ENDIF
RETURN STRCONV(LEFT(cGUID,76),6)
ENDPROC
>>I have to go back to an earlier point in another (or the same?) thread:
>
>>Surrogate keys are the absolute best way to guarantee a unique primary key bar none. Period. And, IMHO, the CoCreateGUID API call absolutely guarantees uniqueness spanning not only the table, but the database, the machine, the network, the freaking
world.
>
>On second thought. You raise an interesting point up here. Unlike many others you do not choose for a separate PK table up here. If I may ask, what are your motivations. How do you store it in the table (data type) ?
>
>Walter,
------------------------------------------------
John Koziol, ex-MVP, ex-MS, ex-FoxTeam. Just call me "X"
"When the going gets weird, the weird turn pro" - Hunter Thompson (Gonzo) RIP 2/19/05