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 2005 Forums
 Transact-SQL (2005)
 Row ID

Author  Topic 

nice123ej
Starting Member

48 Posts

Posted - 2007-08-03 : 12:41:27
hi, i am building view, and i need row id in a column, how to do that?!
e.g.

select RowID(), EmpID()
From EmpTable

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2007-08-03 : 13:25:59
look at row_number() function in BOL = Books Online = SQL Server help

_______________________________________________
Causing trouble since 1980
blog: http://weblogs.sqlteam.com/mladenp
Go to Top of Page

Lamprey
Master Smack Fu Yak Hacker

4614 Posts

Posted - 2007-08-03 : 14:00:24
What Spirit said. But, why? It seems strange to me to add an abitrary number to a row in a view.
Go to Top of Page

stephe40
Posting Yak Master

218 Posts

Posted - 2007-08-03 : 15:30:23
Lamprey,
Probably the most practical use for this would be to display sets of X of rows of a query for displaying on a webpage. Also, not that I advocate this, but you can use the row number to loop though a result set within a stored procedure without using a cursor.

- Eric
Go to Top of Page
   

- Advertisement -