Can anyone explain why the following won't work:

select *,
case
when OpCode='033'
then IDENTITY(int, 1,1)
else SCOPE_IDENTITY()
end as ticket_id
into t_temp_table
from ASCII20030316
order by date,time

I get the following error message:

Server: Msg 156, Level 15, State 1, Line 7
Incorrect syntax near the keyword 'IDENTITY'.

My intention is to add a column the table that increments each time it processes an OpCode 33. I am using the order-by-into construct to force date-ordering.

Thanks