>I'm working on a project inserting data into SQL Server 2005 (SugarCRM) via ODBC and SQLEXEC() etc.
>
>SugarCRM uses GUIDs as primary keys. They're not autogenerated, Sugar's business layer calls NewID() on inserts. If I'm inserting rows programmatically I need to get the primary key values back.
>
>One way to do this is by calling SCOPE_IDENTITY, @@IDENTITY etc. after the INSERT. But, a quick Google found a corner-case bug with these functions that is apparently not fixed even in SQL 2008:
>
>
http://connect.microsoft.com/SQLServer/feedback/details/328811/scope-identity-sometimes-returns-incorrect-value>
>Since this bug seems to crop up in parallel execution, larger installations may be more vulnerable than small ones based on SQL Server Express.
>
>While on the topic, is it possible to execute a stored procedure via ODBC and have it return an output that can be read in VFP? This seems to be the recommended approach.
Yes. I'll have to look at my code at home to tell exact steps in VFP. It has to do with OUTPUT parameters.
One easy way is to have a Select statement at the end of the SP that selects whatever you want as your return code/message etc. Your SQLExec will return it as the (last) result set.
____________________________________
Don't Tread on Me
Overthrow the federal government NOW!
____________________________________