Site Sponsored By: SQLDSC - SQL Server Desired State Configuration
Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
HiIm running a select query and want to return the number of each row returned. This is a sequential number for each RETURNED record not the record number position that they occupy in the table. This appears to be difficult to implement? Anyone have any ideas - even using a temp table,variables? CheersRon
mohdowais
Sheikh of Yak Knowledge
1456 Posts
Posted - 2004-09-15 : 04:59:25
Are you looking for something like this?
SELECT IDENTITY(int, 1, 1) AS Counter, field1, field2, field3 INTO #TempFROM MyTable WHERE ...SELECT * FROM #TempDROP #Temp
OS
spirit1
Cybernetic Yak Master
11752 Posts
Posted - 2004-09-15 : 05:02:26
is this what u need?declare #myTempTable (id int identity, col1 int, other columns)insert into #myTempTable (col1, other columns)select col1, other columnsfrom myTable if this is not what u need give us some sample data...btw rows are not stored in a table in a perticular manner. they aren't orderen on anything unless u specify it in select.Go with the flow & have fun! Else fight the flow
ronaldmacdonald
Starting Member
2 Posts
Posted - 2004-09-15 : 10:33:02
spirit1 and mohdowais - i kinf of used a mixture of both your syntaxes for my particular scenario and it works a treat!thanks guys/gals