General information
Category:
Databases,Tables, Views, Indexing and SQL syntax
Environment versions
Network:
Windows 2003 Server
PMFJI, in the database that I use (sybase Sql Anywhere) @@identity is only visible to the connection that did the insert. Is MS Sql different than that?
>>Hi everybody,
>>
>>We're using SPT and then a special program to make cursor updatable. I see this code to get the last inserted value
>>
>> mysqlexec("select @@identity as keyval",'csrKeyVal', program())
>>
>>which doesn't look entirely correct to me - who guarantees that by doing a separate query you'll get the value of the record you just inserted and not someone else in between?
>>
>>Is there a better way to get the latest value?
>>
>>Thanks in advance.
>
>Of course it is not correct. You cannot even guarantee it doing in the same query batch. There are other and reliable ways like:
>
>select scope_identitity()
>
>select ... from inserted
>
>output clause
>
>Cetin
Previous
Next
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only