Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Last 10 inserted records

Status
Not open for further replies.

Grudge

Programmer
Jul 30, 2002
23
ZA
Hey There,

is there a way to determine which we're the last x rows inserted into the sql table, without using some kind of reference field (datetime, etc.) ?

Thanks for you help :)
 
To elaborate, LAST and FIRST are not relational concepts. By definition, SQL record sets are unordered. SQL Server does not guarantee order of result sets returned by queries unless the Order By clause is used. Thus the only way to get FIRST or LAST rows is to use an order indicator such as an identity column or datetime.

Tables are ordered physically by a clustered index and my experience has been that simple selects from a single table without an order by clause will return results in the sequence of the clustered index, if one exists on the table. However, Microsoft makes no guaranteee that this will always be the case. Terry L. Broadbent - DBA
Computing Links:
faq183-874 contains "Suggestions for Getting Quick and Appropriate Answers" to your questions.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top