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)
 Auto Number

Author  Topic 

rwlopez
Yak Posting Veteran

80 Posts

Posted - 2007-06-12 : 12:30:07
I need to write a query that will create and autonumber for each row in the result set. I know that I can do this with a table and use IDENTITY but is there a way to just put a counter in the SELECT statement?

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2007-06-12 : 12:35:33
Yes. Use ROW_NUMBER() function.

Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"
Go to Top of Page

rwlopez
Yak Posting Veteran

80 Posts

Posted - 2007-06-13 : 14:24:01
Perfect! That was just what I was looking for. Thanks for your help.
Go to Top of Page
   

- Advertisement -