USE Northwind SELECT CAST(0 AS int) AS sqn, * INTO #temp01 FROM dbo.Orders DECLARE @sq int SET @sq = 0 UPDATE #temp01 SET @sq=@sq+1, sqn=@sq SELECT * FROM #temp01 DROP TABLE #temp01 -- or if there's no identity column in the result set USE Northwind SELECT IDENTITY(int, 1,1) AS sqn, * INTO #temp01 FROM Customers SELECT * FROM #temp01 DROP TABLE #temp01