« first day (1652 days earlier)      last day (3217 days later) » 

6:00 AM
Good morning, Once Again Quiet Room
This question has been edited several times and appears more or less salvageable:
1
Q: Update one column based on count of records of grouped value in another column

studentGiven a table CREATE TABLE TABLE_ITEMS ( serial_num int null, item_group int null ); INSERT INTO TABLE_ITEMS VALUES (0,1), (1,1), (2,1),(3,1) ,(4,1) , (0,2), (1,2), (2,2), (3,2), (4,2), (5,2), (0,3), (1,3), (2,3); and so on... I need to know how to run a query which will upda...

On the other hand, the author seems to have abandoned it.
Do you think it would still be worth re-opening it?
I think it would make a nice variation on the problem (unless we've already got an exact same question, that is).
 
Good morning. I guess it's quiet due to time zones.
:)
I have a question : I've read about the FORCESEEK hint. But why on earth , the optimizer would NOT want to do it by default ? It is better for him and it's better for me.
 
This makes me think - I will never know how sql server really works
:(
 
6:32 AM
morning
 
 
1 hour later…
7:49 AM
Morning all
 
morning
 
good morning
 
8:05 AM
morning (:
 
inside out smiley spotted
 
morning!
 
More like upside down
:P
 
:b
well, on my screen the lines run horizontally, so I see no difference between :) and the upside down counterpart :) :D
 
8:22 AM
When you flip your screen to see the standard :) you'll see the upside down smiley (:
 
 
1 hour later…
9:30 AM
1
Q: How to backup MS SQL Server databases off-site?

Paul-Sebastian ManoleMicrosoft SQL Server supports backing up to remote network locations only by means of UNC names the SQL Server (and user account it's running under) has access to. Is it possible to create backups and stream them back to a SQL client by means of using the same database connection? I think you w...

thing is
it is possible
it just doesn't seem like good advice to give :)
though it would work for him
and is a creative solution
not sure if I should post that as an answer as the question is on-hold for now
 
Morning
 
10:00 AM
morning
 
10:28 AM
@TomV I think you should post that as an answer. Assuming the question gets reopened (2 votes needed). Don't really understand why it was closed, I must say.
 
the original question was quite different
 
@PaulWhite reopened
 
to me it appeared it was asking for some rather obscure solution
 
@ypercube Thanks!
 
10:30 AM
@dezso Ah ok thanks.
 
11:07 AM
@ypercube Do you think the conclusion is true that most people answered hastily because they don't want to hear 'no'?
 
@JamesLupolt Not sure about the "most"
Some may just want to find a solution/answer fast.
 
@ypercube That was my guess, that most or many people aren't going to be that invested in a puzzle and would rather see the answer quickly.
 
11:21 AM
@PaulWhite posted as an answer, not sure if I included too much source code or did the attribution right
 
Seems fine to me.
 
11:40 AM
@JamesLupolt but then why do they avoid the sequences that result in 'No'?
 
@dezso I'd guess because the correct answer is slightly less intuitive and requires more effort to test if you aren't that interested
I haven't read the paper linked to, but they might have done something to rule out various motivations
 
11:58 AM
<- Expert on laziness
3
 
12:30 PM
I have a table which contain some information with a Datetime column. I wanted to count how many events were in the past 30 minutes interval — So I did this :
DECLARE @k INT = 30;
WITH cte AS (
         SELECT *
         FROM   Eservices_WebApi_Logs
         WHERE  DateCreated >= '20150713'
                AND DateCreated < GETDATE()
     )

SELECT DATEPART(hour, DateCreated)  AS H,
       (DATEPART(minute, DateCreated) / @k) * @k AS m,
       COUNT(*)                     AS Purchases
FROM   cte
GROUP BY
       DATEPART(hour, DateCreated),
       (DATEPART(minute, DateCreated) / @k)
ORDER BY
       DATEPART(hour, DateCreated),
       DATEPART(minute, DateCreated) / @k;
If I change the @k to 60 it will yield : how many were per hour :
But what if I want to do it per 2 hours ? now @k is not helping and I need to create a group for 2 hours... How can I do that ?
 
Hm, this seems elaborate enough to be posted as a question on the main site.
 
But that question seems a little different. Or you missed something explaining the present problem.
The thing is, your query can return data from several days. However, you are grouping by hour and minute only.
 
Yes I know , I was just noticing that the original question was asked and I probably need to ask a new one for the 2 hours group
 
@RoyiNamir You can use Mikael's answer as a start.
Calculate the datediff from the start of the day (00:00) and then divide by 120
 
12:44 PM
That means that, say, results for the 8:30-9:00 interval from every day will get combined in your present query. Mikael's solution is what I first thought about, and it is what you should use instead of your approach if it really matches your requirements
 
Just for clarity , my solution was based on Bort's answer ( which is also an answer in my post)
But I can see now why Mikael's answer is more appropriate now for my situation.
Becuase now I can really use @k=120
(unless i'm mistaken)
 
@RoyiNamir You are not, Mikael's method is indeed much easier to adapt to the new interval.
To any interval really, provided it's a whole number of minutes.
 
INSERT INTO t2 SELECT 1,2345,0,'LA',100; can (and should) be done INSERT INTO t2 VALUES (1,2345,0,'LA',100);Rick James Jul 10 at 23:12
this sounds strange
 
1:15 PM
Anyone any idea why this happens dba.stackexchange.com/questions/106865/… - the CREATE TABLE script also shows \n for every line - strange!
 
the user probably just doesn't know how to post code.
 
@Lamak I doubt they'd got through the lengths of manually typing \n everywhere
 
@Vogel612 well, the revision history kinda shows he did
 
might be related to this bugreport
@Lamak whether that was the intention is up for debate.
Hello @all, btw
 
@Vogel612 of course, but I've seen user posting entire tables using some html formatting, so adding \n doesn't seem weird at all
 
1:22 PM
@Lamak But if it's HTML, where are the <br>s &c?
 
which \ns are you all talking about? ;)
 
7 mins ago, by Vérace
Anyone any idea why this happens http://dba.stackexchange.com/questions/106865/get-all-data-from-two-tables-and-g‌​roup-it-into-different-category-in-mysql?noredirect=1#comment194412_106865 - the CREATE TABLE script also shows \n for every line - strange!
 
@Vérace <br />, please
@Vogel612 check the question
 
@Vérace I didn't say this particular user was doing that, just that adding \n wouldn't be that much of an effort for a user
 
@dezso Just refreshed - they've gone. Did someone edit? In any case, it's still strange.
 
1:23 PM
@dezso oh okay nvm
 
@Vérace yeah, @dezso did
hence his comment
 
Quick sidequestion...
 
@dezso And you missed a few!
 
I want to compare the results of two queries... they mustn't differ..
is SELECT COUNT(*) FROM (query1 EXCEPT query2) = 0 a good idea?
 
ok
 
1:25 PM
I've actually added those <br /> tags, trying to reflect the OPs intention
 
@Vogel612 what about duplicates?
 
@Vogel612 not really
 
I also find it strange why those \ns were there
 
I do dearly hope there are no duplicates ..
 
@Vogel612 hope or know?!
 
1:27 PM
@Vogel612 I mean, that just means that "results from query1" are contained in "results from query2"
 
well this is for rewriting / cleaning a stored procedure, and I want to check against the old resultset
 
@Vogel612 if I'm not mistaken, they are identical if and only if query1 EXCEPT query2 and query2 EXCEPT query1 are both empty
 
@dezso yup, or that query1 INTERSECT query2 has the same number of rows than query1 and query2
 
^ that seems easier to express..
 
so, when does this ^^ dotted separator line appear in the chat?
@Lamak I am wondering which solution can be more performant effective
 
1:33 PM
@dezso best guess estimate for up to where you read..
if you tab out and stuff happens you get that separator
That's why it's at different places for different people
 
I see actually two of them - is there a second best estimate, too? :)
 
For me it's always there above the last read message.
 
@dezso weird, I do too
 
@dezso more tabbing out I guess..
 
@dezso @Lamak From my experience, if you switch from the chat and back more than once, the line will be drawn more than once too.
 
1:37 PM
they have css-class 'catchup-marker`
hmm ketchup..
 
The line should be red then.
 
catchup-marker-[123]
 
Oh I see, it's called that because it marks read messages. :)
 
the two are now flanking my latest post
fun stuff - but I'm now stopping talking about it :)
0
Q: Recovering data from postgresql xlog

HellOfACodeI lost a lot of data in my postgresql database and do not have a dump file to restore backup from, but i heard that in /var/lib/postgresql/9.4/main there are pg_xlog and pg_clog and that those directories could be used to restore previous points in the db. Could some clarify this and how to do it...

that data need a coffin
 
1:56 PM
okay I think I got a problem..
I didn't change anything and the intersect is already having 0 results T.T
 
@Vogel612 Do you mean it returned some results before but now it doesn't?
 
@Vogel612 can you post a sqlfiddle demo?
 
no... the results are distinct for two invocations of the same procedure
with the same params
because somebody thought it to be a good idea to make the results have a primary key, that's actually populated from a sequence
 
you can use SELECT [every column that's not an identity] INTERSECT SELECT [the same columns]
 
@Vogel612 that sounds useful
 
2:03 PM
but the identity is never used in calling code
.... never...
it's especially moronic when the result set contains two other GID-like identities of two different tables...
 
2:39 PM
funny q:
0
Q: SQL Server transactional replication issue with database

Buda GavrilWe have on the server a database and we want to replicate a database on another server. we've set a transactional replication, but we have issues with the default constraints on the tables: On the left is schema of the table from a backup from the original server and on the right is the schema...

we should point the OP to @Paul's starred message
Jul 9 at 8:27, by Paul White
In short: read everything Aaron Bertrand has ever written.
 
just noticed a q i responded to was posted to @StackDBAs twitter
now i'm wondering what basis the questions are selected on
 
@TomV it could be the no of visualizations..
 
3:15 PM
hello everybody
 
hi
 
do any body knows the algorithm or formula for convert(datetime,doublevalue)
for example
select convert(datetime,42197.8680532407)
it gives 2015-07-14 20:49:59.797
 
the integer part are days that you add from 1900-01-01
and the decimal part would be the time
since 00:00:00.000
 
can you tell me the formula or algorithm please?
 
@SpringLearner he just did
 
3:24 PM
actually in my DB,datetimes are stored in double format like this select CONVERT(FLOAT,getdate())
and to retrieve select convert(datetime,42197.8680532407)
 
@SpringLearner and where is the problem?
 
This had better not turn into stump the chump
 
(except for the really bad decision of storing datetimes as floats)?
 
I have a front end developed in android
 
@SpringLearner that's what I did
 
3:27 PM
So Android applications save datetime values as decimal numbers? Am I understanding that correctly?
 
@Lamak I will explain my problem
 
you take the integer part and add them as days since 1900-01-01, then you take the decimal part and add them as the time. In your example, you should add 42197 days to 1900-01-01, and 0.8680532407 days (which are 20 hours, 49 minutes, 59 seconds and 797 milliseconds)
 
@Lamak To be fair, that's how SQL Server handles datetime values. Maybe Android uses a different formula?
 
@MikeFal I didn't read the android part. He just asked how would convert(datetime,42197.8680532407) work
 
@Lamak @MikeFal do you know java?
 
3:30 PM
nope
 
ok then I will post the algorithm
 
@MikeFal But Android is an OS. Depending on the language you use for an application, datetime types will vary.
 
@ypercube we are not storing the android datetime
lets say we are creatiing a ticket,so from android I am taking all the parameters like name,address,user etc
but the datetime is from sql server
like this
insert into ticket values(androidName,androidaddress,getDate())
@ypercube sorry I did not understand you
 
@SpringLearner ok, sorry. Go on with your description of the problem.
 
@SpringLearner if you are inserting GETDATE(), then what's the issue?
 
3:34 PM
This the way I am doing
public static  Date convertDoubleToWindowsTime(double comTime) {
		long result = 0;
		comTime = comTime - 25569D;
		Calendar cal = Calendar.getInstance();
		result = Math.round(86400000L * comTime)
				- cal.get(Calendar.ZONE_OFFSET);
		cal.setTime(new Date(result));
		result -= cal.get(Calendar.DST_OFFSET);

		return cal.getTime();
	}
If I use this function then the output is 2 days ahead
@Lamak actuallY i consider it is a bad idea
because to show simply a datetime,from android I have to take double value
pass it sql server
convert in sql server
retrieve the response and show in front end
 
@SpringLearner you said you did not use double values in your app.
Anyway, what version of jdbc driver do you use?
 
@ypercube you know java?
 
Which version of driver do you use?
 
@SpringLearner does it matter to help solving the problem?
 
@ypercube I use 3.0
 
3:40 PM
stop asking people "do you know..?"
 
sorry
 
@SpringLearner OK, see this: stackoverflow.com/questions/11296606/…
That would explain the 2 days diff.
The answer syas "use a 4 version"
 
but he asked so version number so I thought he is knowing java and so that I can post my code
 
But frankly, I really have no idea what you are doing with the double values.
The best way is to use a DATETIME column in SQL-Server
and the appropriate datatype in Java
(probably some class with a "Date" in its name)
 
The table structure has been developed a long before
so I can not change them
@ypercube I am having problem in converting double to appropriate datetime
the link is for different purpose
 
3:44 PM
yes, but the answer may be the same
 
the answer may be not because I am using java.sql.datetime
 
@SpringLearner And all this double-converting was your attempt to solve the problem, right?
 
@MikeFal @Marian @ypercube @Lamak please see this ideone.com/AVncBa
 
@SpringLearner No, please. We've seen that.
Update your jdbc version to 4 and let us know if you have the same issue.
 
ok
5 minutes
 
3:49 PM
I'm not a developer, so I can't help you there
 
Me neither (a Java developer).
 
I want to show the output
@ypercube yes still the same problem
I have downloaded 4-2.0
 
@SpringLearner The rows are inserted as you showed above? With insert into ticket values('androidName','androidaddress',getDate()); ?
 
4:05 PM
Spring, you'd be best served by posting a question on StackOverflow for this. Provide your algorithm and sample source values, expected outcome and actual outcomes. Otherwise, you'd likely have more success in a Java chat room. In our collective mind, I suspect we'd all agree your root issue is the wrong data type was selected for storing this date value.
$.02
 
exactly. i like the activity here, but not this kind of activity
 
Oh, come on @billinkc. That was at least $.03. Maybe even $.04.
 
You know good and well no one would pay that much for anything I have to say
 
$0.02 was pushing it. just accepted it for the colloquialism
 
Swasheckle, always got my back
 
4:10 PM
and how
 
@ypercube yes exactly
 
@swasheck Just about right. 1 cent for each day off ;)
Anyone has a document/template about database backup/retention policy or DR?
 
@ypercube "Do it. Often"
3
 
@swasheck test it.
 
goodpoint
 
4:24 PM
Good grief. Query a Simple table to check log ons takss a solid 4 minutes on this thing.
 
4:42 PM
Gah! Teradata why you store time this way!
Can't find anything crap online for how to effectively convert either.
 
@Zane Throw NOLOCK on it, profit
 
yes you are right,integer part gives number of days since 1-1-1900,is the decimal part is in miliseconds? As per my calculation,its not in milliseconds
Current time is 22 hours and 12 minutes and if you convert it in miliseconds then it gives me 79920360 but convert(floar,getdate()) gives me 9256227238 in decimal part. So can you please tell me what's the logic behind it?
 
5:00 PM
@SpringLearner the decimal part is not in milliseconds.
0.0 would be 00:00:00 time
0.5 would be 12:00:00
0.75 would be 18:00:00
 
5:13 PM
So, if you want it in milliseconds, multiply it by 86400000.
 
6:04 PM
user image
4
 
@swasheck That's awesome.
 
i can't take credit for it
but it is quite awesome
 
6:24 PM
@billinkc you around?
apparently the MVP mailing list is enjoying some hilarity
 
@swasheck don't invoke that guy
 
@Lamak he's my primary link to MVP drama
 
ah, then carry on
 
6:51 PM
Nope, mobile atm
 
7:02 PM
Yes, I'm curious as to what has them all riled up.
 
Got it. Tracked down the place where somone locked out our service account. God I forgot how rewarding it can be to figure this stuff out.
4AM support call not only able to solve the issue but track the root cause and put in policy to prevent future error. I love it.
 
@MikeFal ehrmagerd. i got subscribed to something that i didnt want! seems to be the prevailing sentiment
 
7:44 PM
Return code in SP = -4. We know what 4 is, what's -4?
 
the opposite
 
8:16 PM
:)
 
8:34 PM
GABF is the weekend after Denver SQL Sat. come for the learnin', stay for the drinkin'
 
Get A Boy Friend?
Oh. Great American Beer Festival, Google tells me.
 
@PaulWhite if that suits your fancy
 
Not that there would be anything wrong with that.
 
no indeed.
 
y'all are so liberal in here
 
8:45 PM
you say, "liberal" and i say "human"
 
Yep.
 
9:05 PM
I had to bail early from the call so I don't know for certain what's gotten people's knickers in a bunch. There was, may still be, an email distribution group only for SQL Server folk. It appears they are trying to reduce silos and so created one big mailing group to serve the delivery of MS services but ZOMG, UNSUBSCRIBEXE!
20something emails to go but that's my NDA compliant version
The facilities for this year's SQL Saturday here in Kansas City are bonerific
Yes, the converted casino was cool but this building is brand spanking new and they have spent a redonkulous amount of money on creating an environment for learning.
 
9:24 PM
 
hehe
 
@AndriyM especially when a scan is better
 
9:38 PM
@swasheck In which case a seek is more than just not better – it's worse.
 
@AndriyM you're not not right
 
@swasheck Not unlike you, I must not deviate from saying
 
bahahahahahahahahahahahah
 

« first day (1652 days earlier)      last day (3217 days later) »