Fixed SQL Server support for LIMIT and DISTINCT

Resolved bad SQL generated when using LIMIT (simple case) and DISTINCT in combination
by SQL Server. This method is already hacky as anything... suggestions
welcome!