Skip to main content
ErikE's user avatar
ErikE's user avatar
ErikE's user avatar
ErikE
  • Member for 12 years, 10 months
  • Last seen more than a month ago
  • Seattle, Washington, United States
awarded
awarded
awarded
awarded
revised
Loading…
awarded
Loading…
awarded
awarded
awarded
comment
Get rows only joined to certain types of row in another table
Your first EXISTS query will select rows that also do not have all three.
awarded
comment
Why does this derived table improve performance?
P.S. Noting that lat & long are not the same dimensions, pick boundary boxes that are bigger than needed to get a correct/safe pre-filter in all conditions. Still, if there are many points being selected from, this can be a huge speed improvement. Last, if the built-in geo methods support returning points within a bounding box natively, use that instead of my suggested manual bounding box, and definitely instead of calculating the distance to all possible points and then filtering on the calculated distance—because you don't actually care what numeric distance is for unwanted points.
comment
Why does this derived table improve performance?
P.S. You may get even more performance improvement by doing a simple arithmetic box before doing the straight-line distance calculation. That is, filter first for those where the value |LatLong.Lat - @geo.Lat| + |LatLong.Long - @geo.Long| < n before you do the more complicated sqrt((LatLong.Lat - @geo.Lat)^2 + (LatLong.Long - @geo.Long)^2). And even better, calculate the upper and lower bounds first, then LatLong.Lat > @geoLatLowerBound && LatLong.Lat < @geoLatUpperBound && LatLong.Long > @geoLongLowerBound && LatLong.Long < @geoLongUpperBound. (This is pseudocode, adapt appropriately.)
awarded
awarded
comment
SQL server databases stuck in restoring state
@JamesJenkins And what is that alternative? The alternative is the hypothesis that a database could show in state restoring but not actually be restoring. Or it could be at the final step of restoring, with the restore actually completed so that it could actually be set to ONLINE state. So long story short, I think your comment and downvote are out of line for this site and your information is factually incorrect because it is not properly qualified with the data I have presented.
comment
SQL server databases stuck in restoring state
Perhaps you are unfamiliar with how on StackOverflow, we sometimes answer questions that are slightly different from the posted one. This provides value because people often come to questions similar to theirs after searching online. Regarding your factual claim about ALTER DATABASE not being permitted, I assure you that in my case, the database was in fact showing as in restoring state, and using SET ONLINE in fact worked. So realize that you are calling me mistaken or lying. Is that what you really need to do when an alternative is available?
awarded
awarded
1
2 3 4 5
18