Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
MS-SQL - increment AND return new value in one hit
Message
From
29/03/2004 11:04:15
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00890436
Message ID:
00890441
Views:
20
>Howdy, y'all
>
>I'd like to T-SQL to MS-SQL to have it increment a field value and return that new value in one swipe - rather than hitting it twice (trying to eliminate the possibility of duplication).
>
>I suspect I can do a transaction - but I'm afraid that won't really work if someone else is incrementing the same counter at the same time.
>
>How can I do that?

text to m.lcCommand noshow
insert into ...
endtext

SQLExec(m.lnHandle, m.lcCommand)
SQLExec(m.lnHandle, "select @@identity",'lastIdent')

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
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform