Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Migrating to SQL Server
Message
De
25/09/2008 15:56:14
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Client/serveur
Versions des environnements
Visual FoxPro:
VFP 9 SP2
OS:
Windows XP
Network:
Windows 2003 Server
Database:
MS SQL Server
Divers
Thread ID:
01350572
Message ID:
01350771
Vues:
18
>>>For PK/FK we're using "pseudo" GUIDs (just alphanumerical). Should we use uniqueidentifier field in SQL Server for them?
>>>How can we get new ID after insertion using this type of field?
>>
>>I don't know what does pseudo GUID is:) If you use strign form of GUIDs (36 characters, or 38 with {}) on VFP side that is transparently recognizable on SQL as a uniqueidentifier. Yes uniqueidentifier on SQL.
>>
>>It is the beauty of a GUID, you don't need to go and ask server what is my new ID? You create it and use it. Server learns the ID after you do:) No fixup necessary for parent-child-grandchild (and disconnected) scenarios.
>>
>>Cetin
>
>Not sure what do you mean here. When we created a new parent record and want to insert a new child record in the child, what should we use for FK field?
>
>In other words, if I start a transaction in SQL and I have SP InsertParentWithChildren how should I code it?
>
>Thanks again.
>
>Or are you saying that I need to set @NewID = NewID() and put it in both parent and child rather than omitting PK field in INSERT statement?

A GUID is unique whereever and whenever it is created (there is a chance of duplication but considered none as the probability is very low).
Since it is unique and can be created independantly from SQL server you create your PKs. You use the created PK as FK because you know it would be the PK when committed. However you have liberty not to commit at all.

Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform