>I got the thing to work. It may not be the cleanest but it will suit my needs at this point. Basically what I am doing is including the statement "Output inserted.InvRecordNO" in the SQL. If the SQL succeeds then I call "=SQLEXEC(dbHandle,"Select * from inserted") " and then r=VAL(sqlresult.invRecordNo)" . This returns the new primary key to me. I hate to hit the database twice and think it very strange that SQL Server would return the integer invRecordNo as a character string.
>
>Thank you all for your help!
I'm not sure you're getting the correct result with this approach.
Did you try
text to lcInsert textmerge noshow
declare ...
insert into myTable ....
select * from @Output
endtext
sqlexec(dbHandle, lcInsert,'curMyResult')
If it's not broken, fix it until it is.
My Blog