Fixed SQL Server support for LIMIT and DISTINCT

Resolved bad SQL generated when using LIMIT and DISTINCT in combination
by SQL Server. This method is already hacky as anything... suggestions
welcome!
Merge pull request #316 from jamescrowley/limit

Fixed SQL Server support for LIMIT and DISTINCT