September 10, 2007 at 12:17 am
Hi,
anybody got anyideas about how to pull only even rows from a table into a dynamic cursor ?
September 10, 2007 at 1:34 am
Define 'even rows'
Do you have an identity column and only want rows where the id is 2,4,6,... ?
Do you want every other row as defined by a certain order by?
Off the point of the question, why do you need a cursor, let alone a dynamic one?
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
September 10, 2007 at 2:01 am
You could use a query with Row_Number like:
SELECT a FROM ( SELECT ROW_NUMBER() OVER ( ORDER BY a ) AS RowNr , a FROM @evenRows ) AS x WHERE x.RowNr % 2 = 0
Assuming in the above that you want to order on a, and then get every second row.
If you describe your problem in more detail we may be able to help better
Andras
September 11, 2007 at 3:14 am
Hi
Thanks for the replies. It was just somthing i had been playing around with. Yes i was thinking even rows in terms of 2,4,6,8 etc.
September 11, 2007 at 3:48 am
Even, in terms of what? Row position based on a certain order, an identity column, something else ????
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply