How to get row id and row num from sql server tables?
Hi,
I have question: How to get the row id and row number from a sql server table.
In Oracle, just like: "select rowid, rownum, emp_id from emp where emp_id
= 5", but rowid, rownum not in sql server. I tried RID, failed. Can someone
show me how?
One more question, below statement, how can I just display first 100 records
on the screen or data grid control if there are more than 1000000 rows selected?
select customer_id, customer_name from customer where customer_name like
's%'
Thanks a lot.
[561 byte] By [
Sql Quest] at [2007-11-9 21:10:25]

# 1 Re: How to get row id and row num from sql server tables?
see http://www.mssqlserver.com/faq/general-rownumber.asp for row #
for first 100 by id:
select top 100 customer_id, customer_name
from customer
where customer_name like 's%'
order by customer_id
--
HTH,
David Satz
Principal Web Engineer
Hyperion Solutions
"Sql Quest" <pengl@yahoo.com> wrote in message news:3d9c5d1b$1@10.1.10.29...
>
> Hi,
>
> I have question: How to get the row id and row number from a sql server
table.
> In Oracle, just like: "select rowid, rownum, emp_id from emp where emp_id
> = 5", but rowid, rownum not in sql server. I tried RID, failed. Can
someone
> show me how?
>
> One more question, below statement, how can I just display first 100
records
> on the screen or data grid control if there are more than 1000000 rows
selected?
>
>
> select customer_id, customer_name from customer where customer_name like
> 's%'
>
>
> Thanks a lot.
>
>