Viewing 15 posts - 46 through 60 (of 2,171 total)
I get 450 milliseconds when using the algorithm as a scalar function.
I get 1000 milliseconds when using the algorithm as an inline table-valued function.
Using the same 1 000 000 rows...
N 56°04'39.16"
E 12°55'05.25"
December 1, 2020 at 7:20 pm
Are you referring to this function?
https://www.sqltopia.com/algorithms/date-and-time/get-the-nth-weekday-of-any-interval/
I can't see that it should take 4 seconds to run over a million date interval?
N 56°04'39.16"
E 12°55'05.25"
December 1, 2020 at 6:42 pm
As Jeff states, there are so many things that prevent you from doing a simple ALTER TABLE ALTER COLUMN.
I have recently put my sp_AlterColumn on GitHub. I have used...
N 56°04'39.16"
E 12°55'05.25"
November 20, 2020 at 8:35 pm
My goal was to demonstrate you don't need two cross apply.
SELECT SUBSTRING(CONVERT(CHAR(9), DATEADD(MONTH, DATEDIFF(MONTH, 0, t.thedate), 0), 6),...
N 56°04'39.16"
E 12°55'05.25"
November 16, 2020 at 1:57 pm
WITH cteDates(this, limit)
AS (
SELECT MIN(Startdate),
...
N 56°04'39.16"
E 12°55'05.25"
November 16, 2020 at 9:23 am
I use Google...
https://weblogs.sqlteam.com/peterl/2009/07/12/how-to-calculate-the-number-of-weekdays-for-any-given/
N 56°04'39.16"
E 12°55'05.25"
October 17, 2020 at 6:47 pm
-- swePeso
SELECTAccountNumber,
STRING_AGG(Value, ',') WITHIN GROUP (ORDER BY Value)
FROM#TestData
GROUP BYAccountNumber;
N 56°04'39.16"
E 12°55'05.25"
April 5, 2019 at 9:13 am
Be very careful with LAG here. If you for some reason don't have data for the previous measure period, you will get the measure period before that.
That's why why need...
N 56°04'39.16"
E 12°55'05.25"
March 1, 2015 at 2:44 am
The bahaviour is decoumented here
https://msdn.microsoft.com/en-us/library/ms190309.aspx
N 56°04'39.16"
E 12°55'05.25"
March 1, 2015 at 2:37 am
-- SwePeso
WITH cteData
AS (
SELECTDESPATCH_ID,
SAMPLE_ID,
SUBSTRING(SAMPLE_ID, PATINDEX('%[0-9]%', SAMPLE_ID), LEN(SAMPLE_ID)) - ROW_NUMBER() OVER (PARTITION BY DESPATCH_ID ORDER BY SAMPLE_ID) AS grp
FROMdbo.SAMPLE_TABLE
)
SELECTDESPATCH_ID,
MIN(SAMPLE_ID) AS FromID,
MAX(SAMPLE_ID) AS ToID
FROMcteData
GROUP BYDESPATCH_ID,
grp
ORDER BYDESPATCH_ID,
grp;
N 56°04'39.16"
E 12°55'05.25"
March 1, 2015 at 2:34 am
-- SwePeso - Preaggregation/filtering step
SELECTSetID,
COUNT(*) AS cnt,
MIN(ItemCode) AS mn,
MAX(ItemCode) AS mx,
CHECKSUM_AGG(CHECKSUM(ItemCode)) AS chk
INTO#Temp
FROMdbo.SetsItems WITH (NOLOCK)
GROUP BYSetID;
-- SwePeso - projection step
SELECTROW_NUMBER() OVER (ORDER BY w.chk) AS UniqueSetID,
STUFF(f.Data, 1, 2, N'') AS...
N 56°04'39.16"
E 12°55'05.25"
March 1, 2015 at 2:27 am
This is a simple case of Relational Division, of which I am particular fond of.
The result isSetIDSetID
110
211
78
79
89By using this piece of codeSELECTkc.SetID,
nc.SetID
FROM(
SELECTSetID,
COUNT(*) AS cnt
FROMdbo.SetsItems
GROUP BYSetID
) AS kc
INNER JOIN(
SELECTSetID,
COUNT(*) AS cnt
FROMdbo.SetsItems
GROUP...
N 56°04'39.16"
E 12°55'05.25"
March 1, 2015 at 2:18 am
Thank you for taking the time (pun intended) to test the different solutions.
N 56°04'39.16"
E 12°55'05.25"
August 13, 2014 at 6:37 am
DECLARE@Sample TABLE
(
s1 DATETIME,
f1 DATETIME,
s2 DATETIME,
f2 DATETIME
);
INSERT@Sample
(
s1,
f1,
s2,
f2
)
VALUES('2014-08-13 07:00', '2014-08-13 12:00', '2014-08-13 10:00', '2014-08-13 19:00'),
('2014-08-13 07:00', '2014-08-13 12:00', '2014-08-13 09:00', '2014-08-13 10:00'),
('2014-08-13 07:00', '2014-08-13 12:00', '2014-08-13 13:00', '2014-08-13 19:00');
-- SwePeso
SELECTs.*,
x.*
FROM@Sample AS s
CROSS...
N 56°04'39.16"
E 12°55'05.25"
August 13, 2014 at 5:28 am
Viewing 15 posts - 46 through 60 (of 2,171 total)