Identity or Sequence column in non-table SELECT ?
- From: GlennM <GlennM@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Thu, 2 Jun 2005 12:44:02 -0700
I'm looking for a way to specify a column in a SELECT statement
that is a sequence number related to the record number in the result set.
Ideally, just a number from 1 to N.
Example:
Select <???> as Sequence, column1, column2 from table1
The Identity function can do this, but only for SELECT INTO
a new table. I don't want to create a new table.
The NewID() function returns a new global ID, but those
are not sequential.
I was hoping there might be some special variable @@XXX
that represents the row number in the results, but could not find
anything like that in the SQL Server documentation.
Any ideas ?
.
- Follow-Ups:
- Re: Identity or Sequence column in non-table SELECT ?
- From: Hugo Kornelis
- Re: Identity or Sequence column in non-table SELECT ?
- From: Hari Prasad
- Re: Identity or Sequence column in non-table SELECT ?
- Prev by Date: Re: Rename a primary key column
- Next by Date: Re: Identity or Sequence column in non-table SELECT ?
- Previous by thread: Wildcard with Update
- Next by thread: Re: Identity or Sequence column in non-table SELECT ?
- Index(es):
Relevant Pages
|
|