Viewing 15 posts - 646 through 660 (of 1,396 total)
One alternate approach could be to use OUTER APPLY and locate the logouts using SELECT TOP(1). Then you could use ISNULL to assign a default value to cases where there's...
April 29, 2021 at 2:41 pm
If you add GROUPING SETS the non dynamic code looks something like this. Since most people want the total to appear on the bottom row, 2 grouping columns were added...
April 25, 2021 at 2:02 am
Ok nice. Good. This is my cup of tea. I'll take a look and definitely reply. Maybe a few days
April 25, 2021 at 12:14 am
cross apply (values (charindex(',', string),
len(string))) st(cloc,...April 24, 2021 at 11:27 pm
Oops (again). Thank you Jeff. I updated the answer with before/after 2017.
April 24, 2021 at 10:45 pm
It's too broad of a question question because everything depends on the totality of your situation. In general imo clustering on a GUID (which is intentionally random) is likely to...
April 24, 2021 at 10:01 pm
Rereading what both Jeffery and me posted, it's correct and doesn't need editing. The CONVERT is not necessary. Frederico is also correct too. CONVERT will work if the correct format...
April 24, 2021 at 4:09 pm
datetime DOES have a format on convert - and that is what is causing it to fail.
format 1 is US - so date string should be on format...
April 24, 2021 at 3:46 pm
Datetime has no format so using CONVERT with a format code is not necessary. The code should work if CONVERT is completely removed. Or you could use CAST instead.
April 24, 2021 at 1:56 pm
Not too long ago there was a question for SQL Server 2012 with pretty much the same pattern.
April 24, 2021 at 1:33 pm
Yes, no STRING_AGG in 2012. We're in the 2016 Forum 🙂 To revert you could use STUFF+XML instead of STRING_AGG.
April 24, 2021 at 1:25 pm
Not dynamic
select tmp_channel, tmp_entity,
sum(case when tmp_category='Cat1' then tmp_charges else 0 end) cat1,
sum(case when...
April 24, 2021 at 12:10 pm
A man goes to the doctor and says, "Doc, it hurts when I do this." The doctor's response: "Don't do that." What about not deleting the data within the transaction?
April 24, 2021 at 11:40 am
I think you're looking for something like this. The first CROSS APPLY 'cma_check(cnt)' counts the number of commas. The second CROSS APPLY 'wrd_check(cnt)' counts the number of words in the...
April 23, 2021 at 8:40 pm
Viewing 15 posts - 646 through 660 (of 1,396 total)