Viewing 15 posts - 16 through 30 (of 10,144 total)
SELECT a, MAX(CAST(b AS varchar(2)) + c)
FROM (VALUES
('A', 1, 'a'),
('A', 1, 'b'),
('A', 1, 'c'),
('A', 2, 'a'),
('B', 1, ''),
('B', 1, 'a'),
('B', 1, 'b'),
('B', 2,...
September 1, 2020 at 1:06 pm
SELECT a, MAX(CAST(b AS varchar(2)) + c)
FROM (VALUES
('A', 1, 'a'),
('A', 1, 'b'),
('A', 1, 'c'),
('A', 2, 'a'),
('B', 1, ''),
('B', 1, 'a'),
('B', 1, 'b'),
('B', 2, ''),
('C', 1,...
September 1, 2020 at 12:23 pm
If the symbols were the other way around it could be a graphic of a euphemism for falling over.
August 18, 2020 at 3:35 pm
Your result set is dependant upon an order yet your source data has no column defining this order. Is there such a column?
If so, can you provide a script to...
August 14, 2020 at 7:17 am
Thanks for response. So if I understand it correct from the above ....
one block of insert for locations and another for individuals
INSERT into dbo.Locations ...SELECT ....FROM dbo.HouseholdTemp WHERE <conditions>...
June 19, 2020 at 2:45 pm
Sure. I think the logic of this is about right - it's hard to tell because there are so many IF blocks in the code:
INSERT INTO dbo.Locations...
June 19, 2020 at 1:36 pm
You're populating these tables
dbo.Locations
dbo.Individuals
dbo.Households
dbo.ListTypes
dbo.HouseholdMailings
from this table: dbo.HouseholdTemp
You're working on one row at a time in a loop - this is why it's so slow. If you can rewrite it to...
June 19, 2020 at 1:09 pm
Glenn Berry's suite of diagnostic queries is a great place to start:
June 19, 2020 at 10:08 am
The query could be without the cte
select
t1.id, cast(t1.startdate as date) startdate, cast(t1.enddate as date) enddate, cast(td.enddate as date) range_end_dt
from
dbo.test_1 t1
cross apply
...
June 17, 2020 at 1:42 pm
Thank you for your reply and help, this is working but I cannot understand why we are multiplying with 2* to the row number for e and s columns...
June 17, 2020 at 9:53 am
Here's a little sample data generator for anyone wishing to play along:
IF OBJECT_ID('TEMPDB..#test1') IS NOT NULL DROP TABLE #test1
SELECT RowID = ROW_NUMBER() OVER(ORDER BY ID, Startdate, Enddate),...
June 17, 2020 at 9:50 am
Thank you for your reply and help, this is working but I cannot understand why we are multiplying with 2* to the row number for e and s columns...
June 16, 2020 at 3:14 pm
https://www.sqlservercentral.com/forums/topic/consolidate-overlapping-date-periods
SELECT ID, StartDate = MIN(ts), EndDate = MAX(ts)
FROM (
SELECT ID, ts, Snapper = (ROW_NUMBER() OVER(ORDER BY ID, ts)+1)/2
FROM (
SELECT *, se = ROW_NUMBER() OVER (PARTITION BY...
June 16, 2020 at 12:39 pm
Those indexes on EffectiveDate are encouraging SQL Server to implement a triangular join, more about that in a minute. If you've added the EffectiveDate index specifically for this comparison between...
June 15, 2020 at 7:16 am
My apologies, but unfortunately, I am going to need more details. Below is my stored procedure (at least the select portion causing this issue)
SELECT
...
June 11, 2020 at 11:15 am
Viewing 15 posts - 16 through 30 (of 10,144 total)