here is the situation. ASP.net project has several sessions open. a user needs to get the value of a column in the last row inserted in a particular table.
Select CallID from Calls where 'it is the last row inserted'
thanks in advance.
you can email me at !cbmorton!@.!gmail.com!
Chris Morton
Define last row?
maybe this will do what you want but it is kind of dangerous because you might pick up the inserted row from another connection
Select Max(CallID) from Calls
Denis the SQL Menace
http://sqlservercode.blogspot.com/
|||i do want to pick up the last inserted row from another connection|||There is no "last" row because SQL Server stores data as it comes in within its own storage schema. There is only a last row if you do a order of the query executed. There could be also a last *physical* row if the table includes a clustered index, which is physically ordered.
But if you want to have the last row in a resultsset, you have to order it backwards and get the TOP 1
e.g. SELECT TOP 1 SomeColumn From SomeTable Order by SomeOtherorthesamecolumn DESC
BTW, this is a public newsgroups, as long as you have MSN Alerts activated you will get a notice everytime a new answer arrives. Private communication should only be done if the thread is extended immensly due to details asking and answering back and forth, but also then the answer and the solution should be posted back here, to help other which might be in the same situation with a similar question.
HTH, jens Suessmeyer.
http://www.sqlserver2005.de
No comments:
Post a Comment