For a website we are developig using Kentico CMS we wanted to show summaries of subpages of the current page. Along with the name of the document, there should be the introduction tekst from the page. The introduction is entered on the subpage in an editable region.
The menu control uses transformations to show title, date etc. With the following code snippet, any editable region field can be retrieved in the transformation.
Friday, January 20, 2012
Wednesday, April 26, 2006
@@identity
Today we ran into a problem with @@identity returning the wrong value for the newly created row.
I found that using @@identity will return the identity column of the LAST inderted row for the current session. On our table we had a trigger that will craete rows in another table, and @@identity would return the identity value of that second table.
The fix for this is to use SCOPE_IDENTITY() function.
SCOPE_IDENTITY(), like @@IDENTITY, will return the last identity value created in the current session, but it will also limit it to your current scope as well. In other words, it will return the last identity value that you explicitly created, rather than any identity that was created by a trigger or a user defined function.
see: http://www.dotnetjunkies.com/Article/86F0988E-FED4-414F-BA2E-D01D953C11BE.dcik9
I found that using @@identity will return the identity column of the LAST inderted row for the current session. On our table we had a trigger that will craete rows in another table, and @@identity would return the identity value of that second table.
The fix for this is to use SCOPE_IDENTITY() function.
SCOPE_IDENTITY(), like @@IDENTITY, will return the last identity value created in the current session, but it will also limit it to your current scope as well. In other words, it will return the last identity value that you explicitly created, rather than any identity that was created by a trigger or a user defined function.
see: http://www.dotnetjunkies.com/Article/86F0988E-FED4-414F-BA2E-D01D953C11BE.dcik9
Subscribe to:
Posts (Atom)