They want to make sure the values are really distinct. You just don't understand. Sometimes, MS SQL Server gives the wrong answers. I've had very senior DBAs look at the queries and tell me so
We need to do some reporting every night on our SQL Server 2008 R2. Calculating the reports takes several hours. In order to shorten the time we precalculate a table. This table is created based on JOINining 12 quite big (tens of milions row) tables.
The calculation of this aggregation table to...
@billinkc I improved a developer's query performance 1000% (10s to 1s) by rewriting it to avoid DISTINCT and re-arranging the joins so it did index lookups instead of a table scan (gak)
This doesn't make any sense. This works fine: DECLARE @d DATETIME2(7) = '2012-04-05T12:34:56.7777'; SELECT CONVERT(DATETIME, @d); - so I suspect your underlying value is actually not a DATETIME2 type, or gets converted somewhere along the way through a query, view, etc. Since there is no reason for SQL Server to convert the value to and from a string during this process. Can you post a repro on SQLFiddle? — Aaron Bertrand6 secs ago
Can't stand self-answers that actually can't possibly be the real answer to the question. The answer is probably "my bad; the column was actually varchar and had bad data in it."
I was using a MIN function to compare character data in a column that allowed nulls, with disastrous results. ;-) Here's a much simplified example that shows the same kind of thing:
Determine the number of rows in sys.indexes:
select count(*) from sys.indexes;
Run this SQL:
select count(nam...
@SimonRigharts Well, we haven't had a change of room title since (I think) @PaulWhite popped in and prompted the change from TheClusteredIndex. Change is good as a something or other so I'm told...