Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Get the last identity value for a table?
Message
 
General information
Forum:
Microsoft SQL Server
Category:
Other
Environment versions
SQL Server:
SQL Server 2005
Miscellaneous
Thread ID:
01421835
Message ID:
01422011
Views:
39
Dmitry,

To make sure you understand.. pretty much by the time your VFP code gets the max(PKField) value back to it, the value returned can be (read that as WILL BE) out of date.

If you intend to know the PK value that got used to create a record and you don't want to use an SP you'll have to write a block of code like this
insert into blah...
select scope_identity() as PKCreated
Then back in VFP you can use the returned cursor.PKCreated field for child table inserts to link the records to the parent table you just inserted into.

In the long run you'll be better off doing stored procs for this.

>I realize that. But, in the first version of my VFP with SQL Server I am trying to stay away from stored procedures. It will probably be in one of the refactoring versions.
df (was a 10 time MVP)

df FoxPro website
FoxPro Wiki site online, editable knowledgebase
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform