Viewing 15 posts - 1 through 15 (of 1,192 total)
Happy top o' 2023 to all!
I've been absent from these forums for a decent bit (life has been interesting, but not too interesting), but I'm hoping to pop in a...
January 4, 2023 at 12:17 am
I was thinking more about this - realized we can do this:
SELECT weekend_day_count=y/7-x/7+(y+1)/7-(x-1)/7
FROM (VALUES(DATEDIFF(DAY,-53690,'1899-01-01') + 1,DATEDIFF(DAY,-53690,'1900-01-14') + 1))x(x,y)
We can specify the anchor date as 1753-01-01 (-53690) and...
October 23, 2020 at 5:04 pm
I love the use of math to solve this. However, I am stumped as to why/how the math works. An explanation for Dummies would be greatly appreciated.
y /7 --...
October 21, 2020 at 1:17 pm
Jonathan,
That's not the same because of the first expression's using integer math.
The second expression is just giving you 2/7 of the number of days in the specified interval, which of...
October 20, 2020 at 10:40 pm
Just one more thing - be aware of the implicit conversions that DATEDIFF performs when using the DATE or DATETIME2 data types or string dates....
Yeah, I've noticed this when...
October 18, 2020 at 9:29 pm
I haven't gotten to spend very much time on this at all today, so I'm not sure if I've given up on the brevity game (although I'm quickly losing confidence...
October 17, 2020 at 11:42 pm
Jeff,
Thanks for taking a look.
The problem is indeed one of the range (as Jeffrey also pointed out while I typed this up). The math trick won't work once negative numbers...
October 17, 2020 at 4:21 pm
It's late in the day, and I'm below my quota of coffee (all too common these days, I really need to rekindle my coffee habit), but here's another, fairly concise...
October 16, 2020 at 9:21 pm
As long as we're fixated on the number of windowed functions (I'd personally prefer choosing based on overall performance profile over a wide variety of data sets, but c'est la...
October 8, 2020 at 2:48 pm
I played around with this for a while last night, trying to find the most concise complete solution (found one maybe 20% shorter than my previous solution, but its performance...
October 2, 2020 at 4:21 pm
One way:
WITH
numbered AS (SELECT *, rn=ROW_NUMBER() OVER (ORDER BY ID ASC) FROM @T),
grouped ...
October 1, 2020 at 9:03 pm
Did you change everything to BIGINT?
The script Alejandro posted didn't change the size column to BIGINT, and it is INT in the sys.database_files, so could also lead to this if...
October 1, 2020 at 4:35 pm
No worries! I'm glad you got it sorted out.
Cheers!
September 30, 2020 at 5:44 pm
If you haven't already, it's probably worth querying tempdb.sys.dm_db_file_space_usage to see whether it even is version store using all the space.
If it is, then you can start by checking sys.dm_tran_active_snapshot_database_transactions...
September 30, 2020 at 5:40 pm
Ah, if you just want to initialize the new column to zero, then Scott's post has you covered.
Cheers!
September 30, 2020 at 5:20 pm
Viewing 15 posts - 1 through 15 (of 1,192 total)