SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2012 Forums
 Transact-SQL (2012)
 add row number column to query
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

masterdineen
Aged Yak Warrior

United Kingdom
548 Posts

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

MuMu88
Aged Yak Warrior

547 Posts

Posted - 07/04/2013 :  10:10:01  Show Profile  Reply with Quote

SELECT *, ROW_NUMBER() OVER(ORDER BY (SELECT(1))) AS [RowNumber]
FROM YourTable;
Go to Top of Page

masterdineen
Aged Yak Warrior

United Kingdom
548 Posts

Posted - 07/04/2013 :  10:12:11  Show Profile  Reply with Quote
thank you very much
Go to Top of Page

MuMu88
Aged Yak Warrior

547 Posts

Posted - 07/04/2013 :  11:39:37  Show Profile  Reply with Quote
Glad to help.

quote:
Originally posted by masterdineen

thank you very much

Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.03 seconds. Powered By: Snitz Forums 2000