Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Generating Primary Keys in SQL Server
Message
General information
Forum:
Microsoft SQL Server
Category:
Database design
Miscellaneous
Thread ID:
00414202
Message ID:
00415556
Views:
22
>>As Bob said, the call to generate a GUID is a WinAPI call so it will be very quick. And the fact that it is 16 bytes shouldn't worry you. After all, it a 16 byte integer and integers make the fastest keys.
>>
>>Having said that, I use the other way. I have a table of keys but I use a stored procedure to return the next PK. The SP applies the appropriate transaction locking so duplicates are not a problem.
>
>Thanks, I was hoping you would see this *g*. I have read some of your other posts.
>
>So you have a SQL Server table (rather than a VFP table) that keeps track of the next PK for a given table, and you call the stored procedure from VFP, VB, or some other client? And the stored procedure accepts the name of a table, gets the next PK, then bumps up the value and stores it in the table? Are you using Integer keys?

Yes to SQL Server table question. And yes the SP can be called from any front end. Yes, I am currently using integers but because the PKs are generated in a user-defined SP and not some WinAPI call or SQL function, it can be easily changed (relatively). ;-)
Larry Miller
MCSD
LWMiller3@verizon.net

Accumulate learning by study, understand what you learn by questioning. -- Mingjiao
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform