I'd appreciate it if other MSSQL users could give the patch a try.
The one item missing from the ticket is paging, but MSSQL doesn't
support that natively, so any input regarding that problem would also
be most appreciated.
If the Django-users list is the more appropriate place for this
message, please let me know.
Thanks,
Sean
What version of SQL Server have you been testing with? I think in 2005
there is support for paging. This brings up the question of how to
handle different versions of backends.
For 2005 you can use the new ROW_NUMBER() function to help with
limit/offset:
SELECT * FROM (
SELECT ROW_NUMBER() OVER (ORDER BY field DESC)
AS Row, * FROM table)
AS foo
WHERE Row >= x AND Row <= y
For 2000 I've seen people use this approach, which works if your sort
field(s) are unique:
SELECT * FROM (
SELECT TOP x * FROM (
SELECT TOP y fieldlist
FROM table
WHERE conditions
ORDER BY field ASC) as foo
ORDER by field DESC) as bar
ORDER by field ASC
So to get records 81-100, y is 100 and x is 20, and the inner-most
select gets the top 100 rows. The middle select orders these in reverse
order and gets the top 20. The outer select reverses these again to put
them in the right order.
I'm not sure where if the db backends separate responsibilities enough
to allow you to wrap this up nicely in the SQL server backend. But it
might work.