Split query result by half in TSQL (obtain 2 resultsets/tables)

Posted by rubdottocom on Stack Overflow See other posts from Stack Overflow or by rubdottocom
Published on 2010-03-19T16:08:08Z Indexed on 2010/03/19 16:11 UTC
Read the original article Hit count: 150

Filed under:
|
|
|

I have a query that returns a large number of heavy rows.

When I transform this rows in a list of CustomObject I have a big memory peak, and this transformation is made by a custom dotnet framework that I can't modify.

I need to retrieve a less number of rows to do "the transform" in two passes and then avoid the momery peak.

How can I split the result of a query by half? I need to do it in DB layer. I thing to do a "Top count(*)/2" but how to get the other half?

Thank you!

© Stack Overflow or respective owner

Related posts about tsql

Related posts about sqlserver-2005