Viewing 15 posts - 481 through 495 (of 4,087 total)
I've created some test code, not realistic, but the CTE with SELECT TOP(1) is over ten times faster, though has more logical reads.
I also notice that you did not...
July 10, 2019 at 7:49 pm
LEFT is never SARGable. LIKE is SARGable if the pattern begins with a constant.
Drew
July 10, 2019 at 7:34 pm
PIVOTs are not very flexible. I almost always use a CROSSTAB over a PIVOT, because CROSSTABs are so much more flexible (and the syntax makes a lot more sense).
Drew
July 10, 2019 at 7:32 pm
Hi Michael, The indexes recommended by SQL Server are not always the best, the index you would need to try is:
CREATE NONCLUSTERED INDEX [IX98_SampleData3]
ON [dbo].[SampleData2] (ACC,[Name],[Ref],[DATE])...
July 10, 2019 at 4:55 pm
Here's a method that doesn't use ROW_NUMBER()
It also requires two scans of the table and is approximately twice as expensive as a result. It will always perform worse than...
July 10, 2019 at 2:20 pm
Most of these methods don't correctly handle situations where the final value is null (leaving a trailing comma). It's simpler to handle this using leading commas rather than...
July 9, 2019 at 8:41 pm
Most of these methods don't correctly handle situations where the final value is null (leaving a trailing comma). It's simpler to handle this using leading commas rather than trailing commas. ...
July 9, 2019 at 6:03 pm
I believe that this gives you the expected results (although it is different from the results that Des' solution gives). It only requires a single scan of the table.
July 9, 2019 at 2:52 pm
The query that you got from Jingyang Li over at the MSDN SQL Server forum, can be easily modified to get the correct result by simply adding a GROUP...
July 8, 2019 at 6:40 pm
Your sample data has times to the nearest minute. Your expected results has times to the nearest second. There is no way that we can derive data with greater precision...
July 8, 2019 at 5:03 pm
The problem with trying to manage 1,2,3 as well as a,b,c is what happens when you hit 1,a,1? One solution could be to just sign each letter a numeric...
July 1, 2019 at 2:14 pm
This is a fairly standard Gaps and Islands problem.
Drew
June 28, 2019 at 6:45 pm
Here is a query that matches the results for your query. NOTE: I changed your permanent table to a temporary table. WHY DO PEOPLE INSIST ON PROVIDING SAMPLE DATA IN...
June 28, 2019 at 5:08 pm
You didn't provide sample data. Also, what do you want to do with people who have two or more sets that overlap and is it different if the overlap is...
June 28, 2019 at 4:10 pm
These are the only options for pinned status that I can find.
June 26, 2019 at 9:07 pm
Viewing 15 posts - 481 through 495 (of 4,087 total)