Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Oracle equivalent ROWNUM for SQL-Server 2005?

In Oracle PL/SQL I was used to write:

SELECT * FROM MY_TABLE WHERE ROWNUM <= 100;

in order to fetch only the first 100 records of the table named MY_TABLE.

What could be the equivalent SELECT statement in SQL SERVER?

like image 546
UltraCommit Avatar asked Nov 23 '25 13:11

UltraCommit


2 Answers

In SQL-Server You can Use TOP to select the no. of rows.

SELECT TOP 100 * FROM MY_TABLE
like image 50
CM Kanode Avatar answered Nov 25 '25 03:11

CM Kanode


select top 100 * from tbl

column name is required or use *

like image 26
manurajhada Avatar answered Nov 25 '25 03:11

manurajhada



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!