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 2012 Forums
 Transact-SQL (2012)
 add row number column to query

Author  Topic 

masterdineen
Aged Yak Warrior

550 Posts

Posted - 2013-07-04 : 09:59:51
How do I add an additional column to a query that is just simply the row number.

MuMu88
Aged Yak Warrior

549 Posts

Posted - 2013-07-04 : 10:10:01
[CODE]
SELECT *, ROW_NUMBER() OVER(ORDER BY (SELECT(1))) AS [RowNumber]
FROM YourTable;
[/CODE]
Go to Top of Page

masterdineen
Aged Yak Warrior

550 Posts

Posted - 2013-07-04 : 10:12:11
thank you very much
Go to Top of Page

MuMu88
Aged Yak Warrior

549 Posts

Posted - 2013-07-04 : 11:39:37
Glad to help.

quote:
Originally posted by masterdineen

thank you very much

Go to Top of Page
   

- Advertisement -