« first day (2283 days earlier)      last day (2589 days later) » 
00:00 - 19:0019:00 - 23:00

12:34 AM
@SeanGallardy thanks for providing the answer on that.
@ypercubeᵀᴹ nice!
 
1:30 AM
dba.meta.stackexchange.com/q/2732/2639 stupid confusing FAQ and site scope.
 
Good luck changing the fundamental distinction that allowed this site to graduate in the first place!
 
I reject that. So we can either address that point or we can just admit that we're at an impasse.
I've tried addressing this multiple times. That's simple a falsity.
 
Nope it's a fact that's not going to change however strongly you hold your one opinion on it.
 
That's a statement about the community distinct from your original false statement.
However, I agree with that one.
Or at least, it seems somewhat likely.
 
@EvanCarroll What's a "falsity" exactly?
I mean which thing, precisely, is it you are saying is false?
 
1:39 AM
That this site, or that any site, would not graduate without a "fundamental distinction" rooted in something external to subject matter. For instance, the career choice of the person asking the question, or the quality that the question be *sufficiently* advanced, and on topic.

I can't think of a single exception to the mold except this site that requires questions be non-"basic"
 
2:37 AM
Dec 9 '16 at 19:18, by Paul White
Personal view (mod hat off) is that basic questions should be allowed, but the quality bar would need to be as high (perhaps higher) than for more advanced questions.
That's what I said the last time we discussed basic versus advanced, and I haven't really changed my mind on it.
But I am struggling to follow what you mean by "career choice of the person asking the question". Where did that come from? Did you confuse it with the question of who you want to answer your question as a way to distinguish SO from DBA?
 
2:57 AM
@EvanCarroll Why don't you write up a meta question to explain what you propose should happen and why, so the community here can have their say on it?
 
i'll check it out tomorrow
 
I look forward to reading it.
 
 
3 hours later…
6:28 AM
With regards to my blocked process report, I'm unsure why a "U" lock is reported for a regular update statement, would that indicate that SQL Server is still looking for the record that needs updating and not actually already performing the update?
 
Hi @Tomv
 
Hi :)
 
The TechNet Article may shed some light: Lock Modes (Microsoft TechNet)
To avoid this potential deadlock problem, update (U) locks are used. Only one transaction can obtain an update (U) lock to a resource at a time. If a transaction modifies a resource, the update (U) lock is converted to an exclusive (X) lock.
 
Yes but I don't see where anybody is issuing an updlock
At first sight, the locks where the blocking process is not empty all have X locks, not U locks
 
6:45 AM
@TomV well I just found one at 2017-03-20 09:40:45.8062241 which is an U lock.
 
good mornings
 
0
A: multi valued attribute as primary key

Evan CarrollJust to be clear, you can have multi-value primary keys. But PRIMARY KEY means all values in the composite key are NOT NULL. CREATE TABLE d ( i int, j int, k int, PRIMARY KEY (i,j,k) ); INSERT INTO d (i,j,k) VALUES (1,2,null); ERROR: null value in column "k" violates not-null constraint DETAIL...

 
mornings
@TomV I think you might be trying to tackle too many problems at a time. Take a step back and try to separate one issue from the other. Bad disk performance might be causing longer locking duration. Longer locking duration might lead to blocked_process_reports. In some cases lock_escalations seem to be leading to blocked_process_reports.
Have you tried capturing the sys.dm_os_wait_tasks for a period of time and correlating to the xel file? (5 minutes / a quarter of an hour / ...).
 
@hot2use It may sound strange, but at this point I'm trying to understand the BPR more than I'm trying to resolve the blocking
 
7:02 AM
@TomV Then we are down to "standard behaviour"
Data modification statements, such as INSERT, UPDATE, and DELETE combine both modification and read operations. The statement first performs read operations to acquire data before performing the required modification operations.
Data modification statements, therefore, typically request both shared locks and exclusive locks. For example, an UPDATE statement might modify rows in one table based on a join with another table. In this case, the UPDATE statement requests shared locks on the rows read in the join table in addition to requesting exclusive locks on the updated rows.
 
7:23 AM
morning
 
good morning
 
morning
 
@TomV You could possibly reduce the amount of caught BPRs by increasing the blocked process threshold: EXEC sp_configure 'blocked process threshold',10 ; What is your current value?
 
5
 
@JoeObbish thanks, I've added the grant: dbfiddle.uk/…
2
@PaulWhite and that one :) dbfiddle.uk/…
 
7:39 AM
Good morning
 
if you have any ideas for that little issue of mine
2
Q: postgres - pg_dump and pg_restore without roles

Andy KI'm trying to restore a dump without having the appropriate roles on the receiving database. As mentioned here but also here, you need to have the --no-owner as an option, either in pg_dump or pg_restore or both I've used the following command line to create my dump "C:\Program Files\PostgreS...

 
morning guys
 
7:54 AM
it depends
 
@Marian You've been frequenting these quarters lately, almost as before :)
 
@McNets it depends on?
 
@AndriyM trying to get my login and reading habits as before :)
how r things working?
 
Great for me. As in: nothing bad has happened, I'm alive and well, yay :)
 
that's great :). I ran my 1st race (a 10K) this past weekend.. and I survived too.
 
8:03 AM
A 10K race, what's that?
Congratulations anyway!
 
@AndriyM 10 km run
way more complicated than I initially thought
 
Ah, of course. Being slow, sorry.
@Marian Well, I can tell you I have no illusions on my part :)
 
I was slower, relax. All those kids and young people flying around...
 
@AndyK New Zealand guys are about to go to sleep ;)
 
@McNets or party
@PaulWhite never sleeps
 
8:10 AM
morning
 
morning @dezso
someone answered me and the answer was correct
 
@Marian 10 km sounds nearly impossible to me. Are you supposed to run all the distance or is walking for a short time fine in such cases?
 
@AndriyM you can walk all the way if you want to ;)
 
@AndriyM in any running events, you can run and walk if you want to
 
@AndyK that's good. In any case, we know for a while now that if there is only one answer, it is automatically correct.
2
@AndriyM except when there is a time limit
 
8:15 AM
@ypercubeᵀᴹ @AndyK Can you take a seat too? :)
 
@AndriyM you can even sleep while in the race, they'll feed you water and fruits :)
z cube is right, there were a lot of guys doing some kind of intervals, running (too) fast for a km, then walking
 
@AndriyM this book on running by Murakami is highly fascinatiing amazon.com/What-Talk-About-When-Running/dp/0307389839
 
hi @ypercubeᵀᴹ :)
 
@Marian Really? And will they patiently wait at the finish and not formally end the race until everyone has finished (unless explicitly left it)?
 
@Marian that is an extreme way of doing intervals
 
8:18 AM
@Marian hi !
 
@dezso I <3 your heuristic
 
@AndriyM there are even longer races than marathon. See this guy: runnersworld.com/trail-runner-profiles/…
 
@AndriyM this one had a 4h time limit I think (which is enough for even dragging 10k)
 
@AndyK it's not mine, TBH. There was a cave troll on meta (suspended for half a year now) who insisted upon such nonsense.
@Marian ah, one could then do it on all fours :D
 
ha ha
 
8:20 AM
(just trolling. A 10k race is quite respectable.)
 
when I started to run a while ago, I could barely finish 1k ...
 
@dezso I know, seemed funny, probably they were bored.. or testing something
@dezso ha ha, didn't see one trying though
 
@AndriyM thanks.
 
@AndyK and now a marathoner?
 
@Marian Well, as far as I'm aware (I get different figures from different sources), walking at 5 kmph is walking not exactly slowly. Not sure if you can sustain the pace for 2 hours, but perhaps a one-hour nap and 3 hours to cover the distance would be fine for me
 
8:24 AM
yes, thinking about it retrospectively, the more you run, the more you keep going and don't give up, eventually you are doing things you thought you were not capable initially
 
@Marian yep, some kind of sql party...
 
@AndyK nice, I've got my mind to run a marathon, but next year, this one only 10k and maybe the cherry on top a semi
 
@McNets It's a pleasure, don't mention it.
 
@Marian you can try a half, later this year
 
@AndriyM not bad, it's a start :)
 
8:35 AM
@AndriyM I think a fit person can produce 6 km/h for a few hours without a problem. I once had to do 7 with a big backpack (two week's clothing, sleeping stuff and other things, totalling to 20+ kg) for nearly an hour. That was tough.
however, the normal pace is about 4 km/h
 
@dezso That's what seems reasonable to me too.
That being said, I think everyone's actually got their own "normal" speed. And that speed can change, too, depending on how trained (or used to walking) the person is/becomes.
 
@dezso depends on how long your legs are I suppose, I notice people nearly have to run to follow me when I'm walking at a reasonable speed
I'm not sure about the facts, less strides are needed, but it may take longer to take 1 stride
it's just something I noticed
 
I had a bike in the past and at some point could go 30 km in our hot summer without (much) trouble. Even if I was able to manage such a distance now, it would be much, much slower.
 
You have nothing to do with my new e-bike
 
Oh, I know nothing about e-bikes in the first place.
 
8:47 AM
It's a pleasure, no more 200 beats per minute
@AndriyM I left biking 5 years ago, and now I can enjoy it again.
 
@AndriyM no insult intended, but it sounds you need a bit more training :)
however, most people are scared when I say I ride like 50 km at a time
not to mention to occasional longer rides, which give them a heart attack
I mean mentioning them
so I can fully understand what you say. All these depend very much on your habits, condition and even genetics
 
(I would possibly die from that 7 km/h I mentioned above nowadays)
 
@dezso Well, NULL training + more training still yields NULL training, so... :)
4
 
50km could be anything from 1 to 4 hours. Are they scared if you say biking for 2 hours?
 
8:55 AM
But seriously, you are right
 
@ypercubeᵀᴹ yes
 
biking for 2 hours is nothing, usual Sunday routes are between 90 and 120 km, including a break for breakfast
 
A lot of people don't understand you can do X for as long as you want as long as you keep your heart rate under a certain point and you train your muscles to endure the effort
2
and don't forget eating/drinking during the effort
And most also underestimate the importance of a good bike
 
That's rather many points to be aware of. That comes with time and experience. Many give up too early.
 
@McNets the break invalidates it :D
@TomV effectively meaning that people in general cannot ride their bike in an effective manner
 
9:05 AM
@dezso the Holy breakfast never invalidates nothing!! ;)
 
@McNets so on Sundays you do a 40 km and a 80 km ride, for example? ;)
 
@dezso mountain bike ~50, road bike usually 80-90, but lately I only use mountain bike
 
question on postgres admin
I'm trying to setup windows authentication on postgres
I got the 1st part e.g the sspi part serverfault.com/questions/610840/…
however the 2nd part is eluding me a bit
once the users are authenticated
 
@dezso effective or efficient? :)
 
How can I put let's say acmedomain\andyk to a specific role e.g runner
In windows sql server, it looks quite easy but in postgres... I found nothing so far ...
 
9:15 AM
@AndyK you mean using domain authentication in postgres?
 
yes @Marian
 
11
Q: How can I configure PostgreSQL to use Windows Authentication?

Devdatta TengsheI am trying to setup PostgreSQL and allow only certain Windows users to access the data from the database. Setting up Windows Authentication is Quite easy with MS SQL, but I can't figure out how to set it up in PostgreSQL. I have gone through the documentation at http://www.postgresql.org/docs/c...

 
@Marian I got that part
 
aaaa, sorry, also assign a role to it in PG admin
 
oh you mean once I will be authenticated, my username like acmedomain\andyk will be seen in PG admin ?
 
9:23 AM
@AndyK thought so, but I can be very wrong, played too lil with PG
can this help?
 
Thanks Marian. It gives me the start of the solution. I will have to dig deeper
 
9:40 AM
@Marian I knew I was to make a mistake. Of course, I meant performant.
 
@dezso Ha!
 
@AndyK sorry, no idea about Windows
 
no worries @dezso, not everyone is lucky to have a linux env
 
9:57 AM
@TomV the majority of BPRs (16108) are on object_id 265915. That's 16108 events out of 19942 total. Index Issues? Slow IO? Or just a low blocked process threshold which results in everything being caught?
What are your thoughts on this?
 
@AndyK do you use Postgres on Windows in production environment?
 
@AndyK found this gem of @Erwin's
 
@ypercubeᵀᴹ yes, alas
you know, I worked pro-bono , on breadlines for many years. It gave me perspective and distance on the human conditon
Thanks Marian
 
 
1 hour later…
11:15 AM
The error message says nothing about timestamps. It says that the table has not a primary key. Did you post the wrong image perhaps? — ypercubeᵀᴹ 2 mins ago
I have time to draw red arrows but not to read error messages.
 
Nice answer:
"Unfortunately I have not found the answer until I have tested it myself. "
 
Timestamps and peer-to-peer replication. I haven't them used - in my limited experience.
 
@hot2use That's a known design issue unfortunately, no easy fix
 
It's a shame that someone must test something by himself just to get an answer.
3
 
@TomV So if we filter out those, then there isn't much left over. Part of it has been analysed and I can add some more. Should I add my analysis to the already given answer in anonymous form?
 
11:33 AM
@hot2use The blocking in itself isn't the mystery, it's missing node, I fully understand why those processes are being blocked
At least not the blocking in that extended event file I mean
 
11:50 AM
@TomV I thinkg that not all system relevant processes will be monitored as an individual blocking node (can't find the reference I read just a couple of hours ago) . That's why I think the BRP is barking up the wrong tree. It is a legitimate BRP, but because of reasons related to sys.dm_os_wait_stats and not because of concurrent updates/inserts happening.
@AndriyM That's why I mostly set CONCAT_NULL_YIELDS_NULL = FALSE. Except when I'm drinking beer.
@TomV So you have XEL files that are more interesting?
 
12:11 PM
@ypercubeᵀᴹ when I mentionned the human condition I mean the unsound of tons of decisions made by many
 
@AndyK ok.
Postgres works in Windows and many other platforms. But is being developed and primary targeting Unix like environments. The performance may not be best on Windows servers.
But I can understand if for example a database was ported from SQL Server to Postgres, that the OS was kept the same.
 
oh ok
tbh, I'm not really fond of windows so that's why each time, I can throw a stone at it, I do ...
 
haha
We have plans to run Postgres on Raspberry Pi machines. On production!
 
omg! Insane or brilliant, take your pick
 
Image correct. thanks everyone — aasim.abdullah 5 mins ago
@Mcnets ^^ and whoever downvoted
 
12:22 PM
but with postgres on Py, it means it is that you are setting up embedded systems...
 
@AndyK It's still planned. Not sure of the details but the requirements are very low so it makes sense to find a very low spec system to run the server. If you can call "server" somethign that runs on Pi.
 
@TomV in your question you wrote: I ran a server side trace for a while and I get the same empty nodes in a trace file as I do using extended events.
Do you stil have that trace file?
If yes, this procedure might help you analyse the root cause: Original from Michael J. Swart and modified version from David Barbarin
But it still won't tell you why the node is empty.
 
12:50 PM
@ypercubeᵀᴹ Obviously I did
 
1:04 PM
@McNets they have edited
 
@ypercubeᵀᴹ red arrow points to a different place, but answer remains the same: Unfortunately I have not found the answer until I have tested it myself. TimeStamp columns are not allowed. You can't replicate a table if it contains a TimeStamp column.
 
@McNets the image had before a message about Primary Key. Now it is about timestamps.
The wording on the answer itself is ... unfortunate.
 
@ypercubeᵀᴹ yep, then is my lack of attention.
 
@ypercubeᵀᴹ Also the wording of the question is a bit similar.
Technically you can use timestamps, but not replicate the tables :).
 
@Marian They didn't believe the official docs. Posted a question at the site. Waited 20 days. Tested. Confirmed the docs.
One would guess there must have been a faster road to the same result.
 
1:22 PM
@ypercubeᵀᴹ Unfortunately, It took me about 20 key-press to answer this question. dba.stackexchange.com/a/169079/110455
 
@ypercubeᵀᴹ well, it would've been a very difficult test - click click click next..
maybe it was worth the wait
 
@McNets to type it or find the answer? ;)
 
@ypercubeᵀᴹ to find the answer!! I used aasim's method, (unfortunately)
 
@McNets This reminded of a session, maybe 20 years ago, where I had to work with Access 2.0 (or 1.0 can't be sure) in a lab with PCs only with keyboard. No mouse.
 
Thanks @JackDouglas!
 
1:34 PM
yeah @JackDouglas, thanks
 
@ypercubeᵀᴹ @ypercubeᵀᴹ more than 20 sure. (I'm 54 yo) WordPerfect was fun
 
> F2 : Toggles selecting all data in the field or placing cursor in edit mode
 
@ypercubeᵀᴹ haha, good!
 
1:50 PM
@JoeObbish you're welcome :)
you too @Lamak
 
and just to be sure, what was I thankful for?
 
@Lamak something to do with my vNext being better than yours :p
 
@JackDouglas right, it was
thanks!
 
didn't you already thank me for that? I'm confused what the latest is for now…
 
@JackDouglas that was just me kinda messing with you by copying @JoeObbish
 
1:56 PM
I'll store it up for the next time
I meant this one:
1 min ago, by Lamak
thanks!
but I'm just messing with you (not quite as well) :)
 
@JackDouglas ah, that was a thanks for clarifying why was I thankful
weird thing about the TRANSLATE function though. And I may have let it slip that I chat with the guy that made dbfiddle ;)
 
thank you for explaining that, would you like honorary British citizenship?
 
sounds more like a canadian one?
 
similar: more 'sorry', less 'eh'
4
 
I see. But I'm afraid that you guys charge me for something ;)
I don't have the kind of money to be a british citizen
 
2:03 PM
but you'll get a nice blue passport!
 
which won't get you through the channel tunnel
 
@ypercubeᵀᴹ I'm in
 
@ypercubeᵀᴹ do you know any nice and small way to generate series of dates on mysql?
 
2:26 PM
@McNets which version?
 
@ypercubeᵀᴹ thanks, I will use a calendar table. I think it is more understandable.
 
and just better
 
@JackDouglas is Ms. PM closing the gates or what?
 
2:42 PM
@McNets In Maria 10.0+: dbfiddle.uk/…
 
@ypercubeᵀᴹ nice, thanks
 
you can use it to populate the calendar, if the answer is for mysql.
I was using cross joins for that.
 
@ypercubeᵀᴹ The passport is currently still burgundy in colour.
 
@hot2use I read on the Sunday papers that the government plans to spend half a billion to replace them with the British blue ones, when you are out.
acording to the article, the change from blue to the EU burgundy was a "humiliation"
 
But the UN passport for refugees is already blue.
For this purpose the Office in consultation with Governments, produced a model document in booklet form, with a stiff blue cover, resembling a national passport. The High Commissioner’s Advisory Committee on Refugees (predecessor to the present Executive Committee) recommended that Governments issue their Convention Travel Document in conformity with the model prepared by UNHCR.
 
2:52 PM
0
A: MySQL - Merge or split datetime intervals (start date to end date)

McNetsFirst due you need to generate a series of dates, I'd suggest to use a calendar table. CREATE TABLE if not exists calendar ( mdate date PRIMARY KEY NOT NULL ); INSERT INTO calendar values ('20170403'),('20170404'),('20170405'),('20170406'),('20170407'),('20170408'); How do they do it Fir...

 
@hot2use I use a modified version of that in a dba database (datawarehouse) so I can look back in time as far as I want yes but the output of that procedure looks weird for the entries where there isn't any blocking process
I hope to find some time tomorrow to run some of the wait stats analysis and the query solomon provided in the comments
 
3:21 PM
@TomV good hunting
 
3:33 PM
bye
 
3:46 PM
@ypercubeᵀᴹ oh yeah, a humiliation. I can imagine how bad it's been. That colour is an insult to national pride! (I'm actually glad the Hungarian government missed this so far, a nice little controversy about changing the colour of our passports could easily fit their 'politics''.)
 
I had no idea British passports used to be blue.
Quite a dark, navy blue it seems from a quick Googly search
 
@PaulWhite I can't remember what colour Greek passports used to be!
 
@ypercubeᵀᴹ Marbled?
 
@PaulWhite with smurfs!
 
Yeah I'm pretty sure that's right.
 
3:57 PM
TIL
 
Greek passports are issued exclusively to Greek citizens for the purpose of international travel. Biometric passports have been issued since 26 August 2006, with old-style passports being declared invalid as of 1 January 2007. Since June 2009, the passport's RFID chip includes two index fingerprints as well as a high resolution JPEG image of the passport holder. Every Greek citizen is also a citizen of the European Union. The passport, along with the national identity card allows for free rights of movement and residence in any of the states of the European Union and European Economic Area. �...
the marbled smurfs version is missing
 
Maybe you had to pay extra for that?
 
everyone knows that wikipedia isn't reliable
 
@dezso that's the EU one. It was dark blue before.
 
@ypercubeᵀᴹ I actually posted the link that points to the historical ones
 
4:00 PM
Ah, thnx. Blame one-box.
 
@ypercubeᵀᴹ already doing that
 
4:18 PM
@ypercubeᵀᴹ I never realized you has multiple republics in recent history
I knew France had several
 
4:39 PM
@TomV yeah. We were republic, kingdom, occupied by the Axis, military junta and probably in some other forms I forget
 
 
1 hour later…
5:53 PM
thanks, @PaulW
 
@MaxVernon I assumed you deleted the "continue this discussion in chat" link by mistake. I'll remove my comment if you meant to make the chat room inaccessible.
 
@PaulWhite - thanks! I didn't mean to remove the "continue in chat" link.
 
@MaxVernon Righty-o
 
6:17 PM
@MaxVernon BTW your TOP (1)s in that function need an ORDER BY clause.
The ORDER BY in the window function does not count. That's for the window frame.
 
@PaulWhite yah, I thought that, but when I tried it, no complaints. I thought that was because of the window function.
I'll add it back in.
 
which question is this for?
 
2
A: T-SQL Daylight Saving lookup table - poorly performing table-valued function

Max VernonMake your function a schema-bound table-valued-function by adding WITH SCHEMABINDING to the RETURNS TABLE clause. So: CREATE FUNCTION dbo.FN_GetLocalTime_FromUTC_BasedOnTZId (@StartDateTime DATETIME, @EndDateTime DATETIME, @Tzid INT) /*=====================================================...

 
@MaxVernon No complaints? Well you won't get an error message, but TOP without ORDER BY is non-deterministic.
 
@PaulWhite oh man. I'm an idiot. Thanks!
 
6:21 PM
TOP 0 is deterministic
2
 
Oh shush.
 
in actual fact the TOP(1) does break the query. Thanks for pointing that out, @PaulW
 
Nit picking as a Service :)
 
it just happens to work with his limited sample data
 
it looks like you're having fun there Max
Care for more feedback?
 
6:23 PM
lol sure
 
Truncating the table is always a valid approach
 
the inner join is not necessary at all.
 
I haven't looked super carefully at it, but do you need both TOP 1 and the RN = 1 filter?
Also consider clustering on Tzid, DT_WhenSwitch
 
not really... my intent was to remove the need to ROW_NUMBER the entire set twice.
 
Maybe he really needs the ID column for some reason
 
6:25 PM
there are something like 9 million rows in that table if I recall correctly.
 
There are a bunch of issues there to be sure.
 
like I said I haven't looked super carefully
but I see no reason why you couldn't find the row you want with just a few logical reads
 
@JoeObbish Exactly so. The biggest issue I think is overcomplicating the implementation without stating the requirement simply. Also using Id as a proxy for datetime ordering is counterproductive in the query (OVER (ORDER BY D.Id DESC)).
Just a question of simplifying and providing the right index.
I honestly don't know why people fall in love with ROW_NUMBER = 1 so much.
 
I'm not a fan of ROW_NUMBER = 1 at all for most use cases
the estimates are always bad (possibly fixed) and it seems to prevent some query transformations
 
It's indirect at best.
 
6:32 PM
it seems to be good for recursive queries
 
@PaulWhite I think it comes from procedural thinking.
 
and I don't mind it at the very end of a query
at which point the carnality estimate doesn't matter
 
@MaxVernon Quite possibly.|
 
I think that it's seen as a way to avoid joins
"If I use ROW_NUMBER() = 1 I only scan the data once"
 
People also seem to love views with ROW_NUMBER = 1.
Often nested.
 
6:34 PM
@PaulWhite what would be the best way?, apart of "It Depends"
 
@Lamak It always depends on the specific problem.
 
Ha, I knew I got it right
 
Often APPLY TOP (1) ORDER BY though.
 
@MaxVernon I think my attempt would be APPLY in the TVF
and to cluster on the columns that I said
 
@PaulWhite good to know
 
6:35 PM
should be super quick to do both lookups
and very obvious to the optimizer that only one row is returned from the TVF
 
But really in this case it's almost certainly just a simple single seek, when the logic is written out correctly - without nesting CTEs for the sake of it.
 
I'd be very interested in seeing it.
 
@Joe are you going to write an answer there?
I'm sure we'd write pretty much the same thing.
 
oh, well, I can
Max do you want to edit yours?
 
@JoeObbish ha, yeah! and TOP 0%, TOP 100%
 
6:38 PM
I knew someone would appreciate that!
 
Seriously, is there any case where TOP 0 has an actual use? Get the columns perhaps without using system tables directly?
 
@JoeObbish god no. I want to delete that steaming pile of rubble.
once the OP realizes I've steered him wrong with the TOP(1) debacle, I will self-immolate.
 
I'll try to write one before my meeting
can edit it later
guy is on 2008
 
@MaxVernon is there a reason you edited the TOP (1) in the answer back to ROW_NUMBER? You could avoid the second subqueries with TOP 1.
 
I don't think that it matters but can't really test
 
6:44 PM
(I admit I haven't read all the discussion here)
 
a little messy to be sure
 
@ypercubeᵀᴹ I never really took the time to completely understand the timezone calculation to the extent I should have.
just waiting to delete the entire answer.
 
@ypercubeᵀᴹ do you think it's correct now?
 
@MaxVernon I wrote up an answer
It's definitely a rush job so feel free to make edits of course
 
nice one.
 
6:56 PM
Just for fun.
 
oh man
 
Is this wrong?
GO
CREATE FUNCTION dbo.FN_GetLocalTime_FromUTC_BasedOnTZId
(
	@StartDate datetime
	, @EndDate datetime
	, @TimeZone int
)
RETURNS TABLE
WITH SCHEMABINDING
AS
RETURN (
SELECT TOP(1) StartDate = DATEADD(SECOND, dls.DSTOffSetSeconds + dls.GMTOffSetSeconds, @StartDate)
	, EndDate = DATEADD(SECOND, dle.DSTOffSetSeconds + dle.GMTOffSetSeconds, @EndDate)
FROM dbo.DSTLookup dls
	CROSS APPLY dbo.DSTLookup dle
WHERE dls.DT_WhenSwitch <= @StartDate
	AND dle.DT_WhenSwitch <= @EndDate
	AND dls.Tzid = @TimeZone
 
I forgot the ORDER BY too
hahaha
 
I didn't; at least not this time.
 
Amateurs! ;)
 
6:57 PM
lol
 
@MaxVernon Yes because the two dates are not necessarily in the same period.
 
like I said I was in a hurry!
 
It's OK I'm only teasing.
 
00:00 - 19:0019:00 - 23:00

« first day (2283 days earlier)      last day (2589 days later) »