Home All Groups Group Topic Archive Search About

Incrementing column in a query

Author
22 Jun 2006 3:13 PM
Charlie@CBFC
Hi:

I would like an incrementing column in result set of a select query.
Numbers begin with 1 and increment by 1 for each row in result set.  Does
same as counter column in table.  How do you do this?

Thanks,
Charlie

Author
22 Jun 2006 3:21 PM
Aaron Bertrand [SQL Server MVP]
http://www.aspfaq.com/2427





Show quote
"Charlie@CBFC" <char***@comcast.net> wrote in message
news:ua0eA5glGHA.408@TK2MSFTNGP03.phx.gbl...
> Hi:
>
> I would like an incrementing column in result set of a select query.
> Numbers begin with 1 and increment by 1 for each row in result set.  Does
> same as counter column in table.  How do you do this?
>
> Thanks,
> Charlie
>
>
Author
22 Jun 2006 3:22 PM
Anith Sen
Lookup ROW_NUMBER() function in SQL Server Books Online.

For older versions, check:
http://support.microsoft.com/kb/186133/en-us

--
Anith

AddThis Social Bookmark Button