You can use IDENTITY on a #temp table.
IF OBJECT_ID('tempdb..#TableOne') IS NOT NULL
begin
drop table #TableOne
end
CREATE TABLE #TableOne
(
SurrogateKeyIDENTITY int not null IDENTITY (1,1) ,
NameOf varchar(12)
)
Insert into #TableOne (NameOf)
Select Alpha From
(
Select 'A' as Alpha UNION ALL Select 'Y' as Alpha UNION ALL Select 'B' as Alpha UNION ALL Select 'Z' as Alpha UNION ALL Select 'C' as Alpha
) as derived1
Order by Alpha
select * from #TableOne
IF OBJECT_ID('tempdb..#TableOne') IS NOT NULL
begin
drop table #TableOne
end
Output:
SurrogateKeyIDENTITY NameOf
1 A
2 B
3 C
4 Y
5 Z