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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Row Num 2

Status
Not open for further replies.

PeterConnick

Programmer
Nov 26, 2002
21
US
I am new to SQL Server.

In Oracle I can use the word ROW NUM to filter how many rows I will return.

What word would I use in SQL Server

Thanks
Peter
 
There is a TOP keyword. For example....

Select top 100 * from MyTable

This will return the first 100 records. You usually want to use an order by in conjunction with top so that you get the records you expect.

-George

Strong and bitter words indicate a weak cause. - Fortune cookie wisdom
 
Thanks that works.

One more easy one for you.

Now that I have the TOP 100. How can display the a column with values of 1 through 100

example

1 SUV
2 Car
3 Van


100 Truck
 
There is an identity function that "sort of" does what you are looking for. The problem is that it only works with Select Into

Personally, I would number the rows on the client side, if possible. You know that the first record will always be 1, the second record will be 2, the nth record will be n.

-George

Strong and bitter words indicate a weak cause. - Fortune cookie wisdom
 
Check out this FAQ:

How Do I Get a Row Number On Each Row of a Query Result Set?
faq183-3021

--James
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top