Muzzy (le*******@yahoo.com) writes:
You could also add an identity field, so every time you know which
record is the last by querying
SELECT * from <table> where <identity_field> = max(<identity_field>)
The only difference between an IDENTITY column and the rowno I
suggested, is that the IDENTITY column is a row number on table-wide
basis (and the fact that it has the IDENTITY property is irrelevant),
while my row number is one by case basis. Since the table appears to hold
entries about cases, it appears logical to have the case number as the first
column in the primary key. Of course, Justin's actual table may look com-
pletely different, but since he did not supply information, I worked from
the most reasonable design. If the table does not have a row number, but
a global id, the query would be the as the one I posted.
The one you suggest does not work, and would give a syntax error. Even
if you replace max(<identity_field>) with a subquery to fix the syntax,
it would give you the most recently entered row for any case, and not a
particular case, which was what Justin asked for.
--
Erland Sommarskog, SQL Server MVP,
es****@sommarskog.se
Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp