T-SQL trick: How to Know Record Row Number By Id Column
Suppose you have some table id column (i.e. primary key) and you want to know the row number of that key in the table. Since there were deletes you can not rely on this field as is even it is an identity field. So here it goes:
SELECT SUM(1) FROM Employee WHERE emp_id <= @my_id
Friday, September 17, 2004 6:05 AM