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)
 Simple count question

Author  Topic 

trouble2
Constraint Violating Yak Guru

267 Posts

Posted - 2007-12-19 : 08:41:27
Hi, I've got a simple question, and I think I've seen it somewhere before, but I can't find it.

I want to do a select and return a column with the record number in it.

SO Select [something] as Number, column2, column3, etc.
Would return:
1 Column2, Column3
2 Column2, Column3
3 Column2, Column3



The secret to creativity is knowing how to hide your sources. (Einstein)

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2007-12-19 : 08:43:54
[code]select row_number() over (order by somecol) as Number, Column2, Column3, etc
from yourtable[/code]


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page
   

- Advertisement -