This is easy to do on the client. It is hard (and mostly meaningless) to do using SQL.
The simplest way to do on the server side it is to create a temporary table with a count column. After you've built all of the rows into the temp table, create a cursor and number the rows. Keep in mind that you are going to a lot of extra work that is meaningless in a relational context... This is purely a crutch to make identifying rows even easier that is already very easy on the client, but it means nothing to the server.
I'd very strongly suggest doing the numbering on the client side.