1,575 reputation
618
bio website
location Ukraine
age
visits member for 2 years, 5 months
seen 14 mins ago

1h
comment SQL Server - constraint to prevent overlapping dates
In response to the earlier comment of yours where you are giving an example of INSERT that doesn't work, that INSERT doesn't populate a PreviousFinished value, which it must according to the method in the linked answer.
2h
comment SQL Server - constraint to prevent overlapping dates
Or perhaps you are struggling to understand how the method in the answer to the linked question works?
2h
comment SQL Server - constraint to prevent overlapping dates
Regarding your update, I don't really understand the actual problem you are facing. Is this about your table already having ranges that overlap and you wanting to detect and resolve them?
1d
comment SQL Server - constraint to prevent overlapping dates
That's great news, people will come here and immediately see that this question already has an answer. :)
1d
comment What is the correct way to ensure unique entries in a temporal database design?
How would you go about splitting an existing (closed) range into two with this restriction implemented? Doesn't seem possible to me, but I might be missing something. (However, it certainly seems possible with the other variation, the one that allows gaps.)
2d
comment How do I include nulls during comparisons in SQL Server?
CASE value WHEN 26 THEN 1 ELSE 0 END = 0. Beautiful, ever so intuitive and by all means sanest of ways.</sarcasm>
Jul
14
comment Getting unique names when the IDs are different (DISTINCT ?)
+1, although deriving a table appears to be perfectly unnecessary.
Jun
18
comment SQL2542N - No match for a database image file was found based on the source database alias
Does it matter that you are running the command from the /data/home/db2inst1 directory while the file you say is located in /home/db2inst1?
Jun
18
comment T-SQL Calculate average value for Duration Field
Strangely, thanks to you I've just discovered that DATEDIFF(SECOND, '00:00:00', Duration) is actually slower than your original suggestion, but replacing the '00:00:00' (a string) with a 0 (an integer) did make it faster (than your method). Don't know why we've got different conclusions. (If this matters, I didn't use a table in my tests, because I only wanted to test the expressions, so I assigned same expression to a variable in a loop and measured the time.)
Jun
18
comment T-SQL Calculate average value for Duration Field
You could just get the difference in seconds between '00:00:00' and Duration instead of all the string manipulations.
Jun
6
comment Why can't I use a CASE statement to see if a column exists and not SELECT from it?
@MarkSinkinson: Names are checked after the syntax, but yes, SQL Server does that prior to actually running the batch.
Jun
5
comment Count where two or more columns in a row are over a certain value [basketball, double double, triple double]
TIL: PostgreSQL, like MySQL, permits referencing columns in GROUP BY by aliases or ordinal numbers.
May
30
comment MySQL stores 0.00 as 0?
Do you want it displayed as 0.00? Formatting should be done in the application.
May
23
comment How to Handle TimeZone Properly in SQL SERVER?
Such a toolkit would seem to be a great help for a developer. However, a scalar function is a black box to the query optimiser. It means that when I apply your function to a column, the configuration tables you are mentioning will be hit as many times as there are rows in the result set (assuming I use the function in the SELECT clause only). That doesn't seem a nice perspective in terms of performance. I haven't really tested your toolkit, though, so I can't say for sure, that's just a general concern based on what I know.
May
22
comment How can I minimize the risk of accidentally modifying the wrong database?
You mean that would somehow disable access to more than one server from a single SSMS instance? Or what have I missed?
May
15
comment How to find duration in a dataset
You are defining two identical subselects here. This is where using a CTE is helpful, because you can define your subselect as a CTE once and reference it multiple times (just like a view, except it is accessible in a single statement only). Here's one more example for you, this one illustrating how a CTE is re-used.
May
14
comment What is the strategy of query evaluation in DBMS when Limit is used in query?
I believe the point @ypercube is trying to make is that you are mixing groups, pages, likes in the same column, even though they are absolutely different entities. That is what makes no sense.
May
12
comment Get streak count and streak type from win-loss-tie data
Thank you for the clarification. I'm beginning to wish I hadn't upvoted your answer 20 min ago, because upvoting it now would have given me much greater satisfaction.
May
12
comment Get streak count and streak type from win-loss-tie data
Impressive! Is there a particular reason why your recursive part's WHERE is using EXISTS (... INTERSECT ...) instead of just Streaks.streak_type = CASE ...? I know the former method can be useful when you need to match NULLs on both sides as well as values but it's not as if the right part could produce any NULLs in this case, so...
May
8
comment Get streak count and streak type from win-loss-tie data
+1, I like the trick of using the descending order in LAG to later determine the last streak, very neat! By the way, since the OP only wants team IDs, you could replace FantasyTeams JOIN FantasyMatches with FantasyMatches CROSS APPLY (VALUES (home_fantasy_team_id), (away_fantasy_team_id)) and thus potentially improve performance.