Select in SQL Server with Intel

Asked

Viewed 845 times

1

I wonder if it is possible to select in Sql Server a table that does not have an index column, but in this select display a sequential index column in ascending order. Ex. Table: Lettering

Coluna
D
E
S

And by making the select of this table, present to me the result:

Indice Coluna
1        D
2        E
3        S

Is it possible? Because I need to import data from one database to another.

1 answer

3


I managed to find a solution, I will post, maybe help someone else.

Select ROW_NUMBER() OVER(ORDER BY GETDATE()) as Indice, Coluna from Letras

In case row_number() needs to have an over() that receives a mandatory orderby. As I didn’t want to sort by any column, but in the order that the data was inserted in the table, I used the order by GETDATE().

Browser other questions tagged

You are not signed in. Login or sign up in order to post.