Viewing 15 posts - 346 through 360 (of 4,087 total)
When posting to an international forum, it is best to use a date that is internationally recognized. ISO suggests using YYYYMMDD, but YYYY-MM-DD is acceptable alternative.
What is so special about...
October 22, 2019 at 7:40 pm
The main argument I have with this article is that he uses frames without ever defining the term. Also, I've never found a need to use the frame UNBOUNDED PRECEDING...
October 22, 2019 at 3:12 pm
You are just as capable of Googling this as any of us. SSMS is designed for writing queries, not manipulating the results, so I'm not optimistic that you will find...
October 22, 2019 at 3:05 pm
You're looking for the table-valued functions sys.dm_sql_referenced_entities()
and sys.dm_sql_referencing_entities()
. These will not show cross database dependencies. You may also want to look at Redgate's SQL Dependency Tracker 3.
Drew
October 18, 2019 at 9:30 pm
This is just BAD table design. You'd be better off totally redesigning this process.
Drew
October 18, 2019 at 4:46 pm
below86 is wrong about how the CTE works. A CTE is not a temp table, but rather a temp view, and (just like a view) you can update the underlying...
October 18, 2019 at 4:39 pm
I think the following is the best approach:
October 17, 2019 at 8:14 pm
This looks like you are trying to do an UPDATE. If so, then
UPDATE YourTable
SET columnB = CASE
...
October 17, 2019 at 4:54 pm
Drew,
To better understand can you please supply a re-structured query that would achieve the same results. This would help to put a method to result
You learn more by trying...
October 17, 2019 at 4:45 pm
In case you're not aware LEAD(WhatWeight,1) OVER (ORDER BY WeightDte desc)
is equivalent to LAG(WhatWeight,1) OVER (ORDER BY WeightDte)
. In this case, it is right to use LEAD()
because the sort...
October 17, 2019 at 4:01 pm
This may perform better. It's hard to tell with such a small sample size.
WITH data_dates AS
(
SELECT s.PlanId, dt.dt
FROM #Source AS s
CROSS APPLY (VALUES(s.StartDate), (DATEADD(DAY, 1, s.EndDate)) )...
October 16, 2019 at 8:25 pm
SELECT getdate() AT TIME ZONE 'Eastern Standard Time';
This will only work if the local time IS Eastern Standard Time. If the input date doesn't already have an...
October 16, 2019 at 6:53 pm
You should be using SYSDATETIMEOFFSET()
if you are going to be switching time zones.
SELECT GETDATETIMEOFFSET() AT TIME ZONE 'US Eastern Standard Time'
If you need to, you can...
October 16, 2019 at 6:46 pm
Google "gaps and islands problem". Using that approach should perform better than joining to a numbers table, especially if the number of missing ids is very small relative to the...
October 16, 2019 at 4:58 pm
Certain windowed functions require a frame when there is an ORDER BY
clause. MAX()
is one of those functions. So MAX(t.end_date) OVER (PARTITION BY t.customer_id ORDER BY t.start_Date ) AS...
October 16, 2019 at 4:49 pm
Viewing 15 posts - 346 through 360 (of 4,087 total)