How can I add an auto increment row in a query?
Existing table: Names
Name
John
Jamie
Adolf
Nelson
Tony
George
Kevin
I want to make a select ... into query (to create a new table)
The result has to be
ID Name
1| Adolf
2| George
3| Jamie
4| John
5| Kevin
6| Nelson
7| Tony
How can I insert the auto incement ID column in my posted code? I am a newby to T-SQL language.
Existing table: Names
Name
John
Jamie
Adolf
Nelson
Tony
George
Kevin
I want to make a select ... into query (to create a new table)
Code:
SELECT Name
INTO NewNames
FROM Names
ORDER BY Name
GO
The result has to be
ID Name
1| Adolf
2| George
3| Jamie
4| John
5| Kevin
6| Nelson
7| Tony
How can I insert the auto incement ID column in my posted code? I am a newby to T-SQL language.