Create an ID Field On the fly in SELECT statement (WITHOUT INSERT)
Posted on 2005-02-25
Basically, I'm trying to do some calculations on a subquery, and in order to pull them off, I need each record that gets returned from the subquery to be numbered, in order.
SELECT IDENTITY(int, 1,1) AS ID, *
t_item = '35697-0101'
order by t_date
as my subquery, but it comes back with :
The IDENTITY function can only be used when the SELECT statement has an INTO clause.
Yes, I know i can use temporary tables, but I'm trying to not have to do so.
Is there any other way to create an incrementing field on the fly?