Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 select query

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2005-11-15 : 07:39:05
narendra writes "hi,

i want to display last 'n' records in my table,
it does'nt contain any identity column or time stamp,
and i want the result as they r stored in the table.

one more query is how to display the records in reverse order
like from bottom to top of da table

regards

naren"

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-11-15 : 08:03:26
There is should be some unique columns to do this
Copy the data to other table with Identity and Use Top and Order by

--Top 10
Select top 10 columns from yourTable order by uniqueCol Asc

--Bottom 10
Select top 10 columns from yourTable order by uniqueCol Desc


Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

blindman
Master Smack Fu Yak Hacker

2365 Posts

Posted - 2005-11-15 : 08:39:29
Data has no order in a database unless you specify one. The concept of FIRST or LAST is meaningless without a sort order, and you cannot rely on getting the same results each time you run your statement.
Go to Top of Page
   

- Advertisement -