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)
 adding an identity column in query

Author  Topic 

scottichrosaviakosmos
Yak Posting Veteran

66 Posts

Posted - 2010-09-06 : 05:35:58
i have a qurey which i am creating joining 4 tables by join .

now when i get resultset i want a new column to add like Srno(serial no.)
which will display the numbers for each row, as if it behaves like an identity column. how to add this column to my already existing query.

scoo

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2010-09-06 : 06:10:41
Use ROW_NUMBER() windowed function.



N 56°04'39.26"
E 12°55'05.63"
Go to Top of Page
   

- Advertisement -