« first day (1687 days earlier)      last day (3195 days later) » 

5:36 AM
@billinkc Surströmming is usually not allowed on airplanes. Not checked in. The consequences if one can accidently should open is just too severe.
 
6:15 AM
@billinkc Above should be "Not even checked in".
 
 
1 hour later…
7:23 AM
Any mongo db-ers here...I am unable to import data as per that Import Dataset Example (in their docs)... docs.mongodb.org/getting-started/shell/import-data
 
@deostroll No MongoDB people among regulars here so far. If you stick around, you'll be first :)
 
7:53 AM
@deostroll Sounds like something can't understand Unicode. There are a few people who answer MongoDB questions on the site, but no one in chat that I'm aware of.
 
8:28 AM
This one is asking for a MySQL solution, but their code is using some PHP framework:
0
Q: How to increment field value count using MySQL

user71959I have a student attendance table. Fields/data sample id | studid | smonth | syear | total_p | total_a 1 | 20 | 08 | 2015 | 1 | 0 2 | 21 | 08 | 2015 | 0 | 1 3 | 22 | 08 | 2015 | 1 | 0 Those are the first entered values. Then I again enter ...

If the framework qualifies as a DB tool, I guess it would be on-topic here, but then the question may need some additional tags, I'm not sure what they should be.
I mean, just adding wouldn't make much sense, as PHP itself is not a DB tool.
 
8:41 AM
is creating an sql insert into two tables with one to one relation not possible? i seem to get a pk null value error.
or am i just doing it wrong? :P
 
@marcusdoesstuff How are the tables and the relationship defined and what are the INSERT statements?
 
9:16 AM
@AndriyM parent table has an autonumber PK that i would ideally want to directly relate to the PK in the second table.
the insert statement is within a script. the first part goes as follows (the values are from a data elsewhere in the script): INSERT INTO Products (ProductNumber, ProductName, InternalID, IdentifiedUses) VALUES (?, ?, ?, ?).
when it does the same thing for the second table, then it errors, presumably because it's clashing with that one to one PK.
i can do it manually in access no problem but i want to do it in code so it can be fully scripted.
 
So this is Access then?
 
it's a .mdb
but the code is a python cvc scraper script, using pyodbc, with sql commands at the end.
 
Presumably there should be some built-in function in Access that returns the last generated autonumber value. You probably want to use that function together with the values inserted into the second table.
 
essentially, it's just a microsoft sql database. i don't need access open to run the script. but i'll have a look around to see if i can find something like that.
actually sorry it is running "Microsoft Access Driver" so you're right
 
The second INSERT might look like this: INSERT INTO ProductHaz (ProductFK, SignalWord, PhysicalHazards, Contains) VALUES (LAST_AUTONUMBER(), ?, ?, ?)You'd only need to get the names right (the FK column and the function)
17
Q: Autonumber value of last inserted row - MS Access / VBA

a_m0dI have a JET table with an auto-number as the primary key, and I would like to know how I can retrieve this number after inserting a row. I have thought of using MAX() to retrieve the row with the highest value, but am not sure how reliable this would be. Some sample code: Dim query As String ...

 
9:25 AM
heh, i had just found that :)
 
OK :)
 
what you wrote before that is most helpful though
 
9:50 AM
I can't believe I'm going to ask for this, but who is the current moderator?
 
Hi Andriy
you've been following the question
 
Yes
 
0
A: BCP Command in SQL

Craig EfreinNow that I better understand that you are trying to extract data, here is a new answer. This just simply extracts data from a table that I created in tempdb. use tempdb -- drop table mytable create table mytable (id int, customer_name varchar(55), cityname varchar(55), statename varchar(55))...

so you've seen my last comment
on AA.SC answer
 
I have this suspicion that the author thinks that their answer is an improvement of yours.
I'm just not sure how to resolve this without creating hostility
 
9:54 AM
perhaps, but it was pretty rude
 
You are free to downvote (as always)
 
done
not cool at all, and after 126 answers without any hostility, this is a first
 
10:14 AM
cur.execute("INSERT INTO ProductHaz (Product_FK, SignalWord, PhysicalHazards
, Contains) VALUES (?, ?, ?, ?)", @@IDENTITY , data['Signal word'][0], data['Phy
sical hazards'][0], data[Contains][0])

^
SyntaxError: invalid syntax
that ^ is pointing at the end of data[Contains][0].
i know that's half pyodbc and half sql but maybe someone has an idea?
the Contains bit was working before i made table relationships and tried adding that @@identity function
 
10:32 AM
figured it out.
needed to move @@IDENTITY into the actual value field rather than after it. eg. VALUES (@@IDENTITY, ?, ?, ?)
@Andriy M And now that I figured that out ^
My one to one relationship is working correctly through my script. :) thanks for your tips.
 
@CraigEfrein were there comments in that q that got removed?
 
10:50 AM
@ypercube Before my second comment, there was a comment by the answer's author where they claimed they posted their solution before Craig edited in the same into his answer.
 
11:01 AM
@marcusdoesstuff That's great, happy to help!
 
11:25 AM
@ypercube Not really sure. I don't remember removing any of my own comments. I may have updated my comments but just for spelling.
 
11:36 AM
@CraigEfrein The answerer did remove at least one of their comments. It was their response to both of us where they said you added the quotename solution after their answer. Possibly they removed it before you had time to read it.
Don't think they were trying to deceive anyone, though. Probably they just made a mistake. I'm removing my responses as well.
 
11:51 AM
Thanks @AndriyM for the assist. It was certainly an unintended mistake on his part, but the reaction afterwards was deceitful in my opinion.
 
12:40 PM
0
Q: SQL Server 2005 Log file used pecentage does not drop after multiple backups

user209436SQL Server 2005 I ran "dbcc SQLPerf(logspace)", then took two log backups, and ran "dbcc SQLPerf(logspace)" again. No change from 48.55% used, even though "dbcc opentran (foo)" says that there are no active open transactions. Does that mean that there are inactive open transactions that are pr...

 
1:06 PM
^^^ This Meta Q was mistakenly posted to Meta, should be on the main site. Can our moderators help with that?
 
1:17 PM
@MarkStorey-Smith, @MarkSinkinson, @MartinSmith, @JamesLupolt, @JackDouglas, @ypercube - do we want to move from Fri 28 to avoid the Underground strikes? We could do Thurs 20 (this Thurs) and @MarkStorey-Smith can make it. Otherwise, to the following week?
2
 
Yey for 20.
 
1:33 PM
@AndriyM So this @@IDENTITY function worked for my first line... It even worked on the second... But on the third time it broke. :(
@AndriyM gist.github.com/marcusdoesstuff/17cbd36b88f05b4b6d80. I get this error on the last line of SQL:
pyodbc.IntegrityError: ('23000', "[23000] [Microsoft][ODBC Microsoft Access Driv
er] You cannot add or change a record because a related record is required in ta
ble 'Product'. (-1613) (SQLExecDirectW)")
If I take out the last line, it works fine... If I replace the third line of SQL there with the 4th, it also works! As soon as I have both lines there, it gets stuck.
 
@marcusdoesstuff Does [Product Hazards] have its own autonumber column? Does [ProductHPhrases] have its own autonumber column?
The @@IDENTITY function returns the last inserted autonumber value. If you inserted a row into a different table, the new @@IDENTITY result will pertain to that table.
 
@marcusdoesstuff I think you need to save the @@IDENTITY after the 2nd statement and then use it (the saved value) in statements 3 and 4.
(because of what AndriyM explains above)
 
So, if you want to re-use a particular @@IDENTITY value, especially if you want to re-use it in various INSERT statements, you need to read it separately, then pass as another input value
 
ah so it worked a 2nd time because the first was a 1 to 1
 
And it's a better habit to use scope_identity() over @@identity lest you stumble into madness due to triggers
 
1:41 PM
It worked because you were using each @@identity value once. In your 4th statement, you used @@IDENTITY and you wanted the identity from the 2nd statement but it used the last one (from the 3rd statement)
 
scope ident doesn't seem to work for access databases?
 
Oh sorry. Access. I tap out
 
let me check tho
it could have been another error earlier :P
hmm yeah i read somewhere that @@identity works for access and the scope_ident doesn't seem to work for me right now.
 
@ConcernedOfTunbridgeWells I can't do this Thursday, sorry
 
1:55 PM
don't let me stop you from doing it though :)
 
hmm... bit confused about how best to store and use that @@identity value.
can anyone give me a hint on what to search for?
 
2
Q: How to get a SQL Server stored procedure return value using pyodbc?

Matthew GliddenMy team's using a python-based wiki server that calls stored procedures on a SQL Server database. Ideally, we'd like to return integer values (1,0,-1) from the stored procedure to show basic results. According to a 2008 thread on Google Groups, return values aren't supported by pyodbc, so the al...

Based on that, I'd think you'd need to change your logic to get the identify value back
 
thanks!
 
ProductId = int(cur.execute("INSERT INTO [Product] (ProductNumber, ProductName, InternalID, IdentifiedUses) VALUES (?, ?, ?, ?); RETURN @@IDENTITY;", data['Product number'][0], data['Product name'][0], data['Internal identification'][0], data['Identified uses'][0])).fetchone()[0])
There I'm using the RETURN to pull the @@Identify value and then the fetchone to capture the return value, cast to an int and then assign to ProductId
In theory at least
 
okay well i might need to look some of that up :P
 
2:15 PM
@billinkc can they also use select @@identity; ?
 
@ypercube Wasn't sure the syntax. Since the linked question indicated it was how to get the return value, I didn't want to deviate. The other articles indicated I would need to use a cursor to get rows back
I never used pyodbc in my python days, since I was always in a MS environment, I used the ado drivers
 
it does seem like there should be a neater way to do this for these. perhaps i'm looking at it the wrong way.
 
If I knew I was loading all of those tables, I'd have one large block of SQL that does it all
Instead of loading product table, getting id. Calling back in to set the hazard, etc
 
@marcusdoesstuff For neater, look at Postgres ;)
 
ONE SQL BLOCK TO RULE THEM ALL
ONE SQL BLOCK TO WRITE 'EM
ONE SQL BLOCK TO GET IDENTITY
AND IN THE STORAGE FIGHT THEM
2
 
2:27 PM
@bluefeet did you survive your work in the atic?
 
@marcusdoesstuff which version of sql server
 
@Zane yes but I'm covered in bruises from leaning/kneeling on the rafters
 
yeah, I'm still a newbie. :P
 
Dudes, SQLCMD is freaking sweet
:setvar ServerName                  "PASQL44I2HELLO"
:setvar DatabaseName                "WORLD"
:setvar OrderIdsSeparatedByCommas   "000000"

if not exists ( select * from [$(ServerName)].[$(DatabaseName)].[dbo].[vendor_client_orders] where vco_oid in ($(OrderIdsSeparatedByCommas)) )
    begin
    select 'Order(s) [ $(OrderIdsSeparatedByCommas) ] not been sent /  null.'
    end
else select -- etc ...
 
@bluefeet Next time, buy some shin guards. That looked unpleasant
 
2:33 PM
^ Works like a charm
 
@billinkc I bruise really easily. That photo was a combo of the rafters, leaning on a ladder all weekend, plaster and debris hitting my legs during demo. It doesn't take much for me to bruise. The people at my gym tell me "I'm a peach"
 
@swasheck the Access one
 
waitwat????
f that noise
 
i need to go take another shower. i just got close to something with access
;)
kidding
butnotreally
 
2:46 PM
we have access on the computers here and some users can actually kinda use it.
they are not technical at all.
it's not a huge db anyway. max 1-2k records.
 
Hey! You lay off MSACCESS.EXE
That was where I first learned SQL and programming with a UI
It's very accessible
it's just shit for maintenance lol
 
@jcolebrand and concurrency
 
@swasheck whoa whoa whoa
let's don't talk about them fancy words like that
@marcusdoesstuff did you know you can format text in chat?
 
break it up! break it up!
 
2:48 PM
select thing
from place p1
join otherplace p2
 
errrr yeah but i can't remember how :P @jcolebrand
 
select thing
   from place p1
   join otherplace p2
use ctrl k or on multiline input look at the input commands -> on the right
 
i'll try that next time.
 
And to do a multi-line input, press Shift-Enter
 
got that bit at least already :)
 
2:49 PM
@AndriyM lol, right, that was what I screwed up a moment ago. Can never remember on OSX if folks want shift enter or cmd enter or ctrl enter
 
@jcolebrand I usually prepare a multi-line block elsewhere, then just paste and Ctrl-K
 
it's the ad hoc comments that kill me
the ones that need multiline I am copying and pasting
 
Because I confuse it with Ctrl-Enter that I use in Skype
 
and if all else fails ... WHO CARES??!!!!! it's a chat. yeesh
 
3:03 PM
I forgot what a phenomenal album "I got Dem Ol Kozmic Blues Again Mama" by Janis Joplin is.
 
hm. i was just listening to local h. very different
 
3:14 PM
Not familiar.
 
but sit down in that chair right there and let me show you how it's done
@Zane 90s band. on to charlie daniels
 
You know. It's still 400 ssome days away from the effing election so Why am I hearing so much about it.
 
You want bread or you want circus?
 
I want to be left alone.
 
@billinkc WITH 2 YOU GET EGGROLL
 
3:21 PM
Ok, but I like the springroll better, can I do that with an upcharge?
 
negative ghostrider
 
3:40 PM
Do we have interest in this here?
-1
Q: AlwaysOn Manual failback not working correctly

Jay PI've set up a small fail over cluster using AlwaysOn in SQL2014 and Windows 2012R2. The cluster (SQL-CLUSTER-DEMO) just contains 2 SQL nodes (SQL-01 [Primary] & SQL-02 [Secondary]) and a file share quorum. Availability Group is set up in SQL server no problems. I am connecting to SQL-CLUSTER-DE...

 
Likely to get better love over here than there but I know Fck all about AG stuff
 
Same no opportunity to play with it yet.
 
Beyond call Allan or Joey
 
4:11 PM
I don't follow that one sorry.
 
And Joey's at joeydantoni.com At least they're the people I think of when it comes to cluster stuff.
Honorable mention to Ryan J Adams
 
summer of '69
;)
 
What part of the SharePoint lists need to be identical across all environments is so hard to grasp.
 
the sharepoint part
 
4:26 PM
^^ amen. I really hate that product.
Using it as a data source is a fools errand.
I constantly advise against it but we are drastically increasing it's usage.
 
Sharepoint lists a good idea, in concept. Enable the business users to curate their data in something that is auditable, backed up, etc
In practice though, I'd rather wash with bacon soap and swim in crocodile infested waters
2
 
It would be nice except. Interacting with it is a nightmare. The list performance goes to hell if it has any amount of data in it. You either need to set up a database sync to have a reliable connection or use the impossibly wonky SharePoint list adapter.
 
@billinkc who wouldn't like to wash with bacon soap?
 
@billinkc sharepoint is the victim of being a good, but halfassed implementation, upon which other vendors bolted cool things prompting a microsoft purchase and halfassed integration. it's a frankenstein.
 
I've said in several meetings that choosing SharePoint as a datasource would be the equivelant of shooting our project in the face. Yet every time it looks like the easiest solution on paper.
Gee we can set it up so easy and the ETL doesn't take long. Oh wait now we made 1 change and our entire project is broken. Oh no now the list is too big so it won't load. We'll have to archive that data off and build reporting for that too.
Goly building a nimble web app would have been so much easier.
 
4:37 PM
The good thing is that the MS push of everything must be in SharePoint seems to be going away
 
leaving corporate carnage in its wake
 
4:55 PM
Am I alone in thinking it should be noted in this article that the reason the clustered columns are included is for key lookup purposes.
 
oh, come on, I just gave you an explanation
Yes, i try the query that you suggested before posting the question. It is working when using ' ' in col1. But it is very strange, how this query is working "SELECT b.col1,b.col2 FROM table b WHERE b.col1=123 AND b.col2 like '%59%'" with out using ' ' — Venkata Seera 4 mins ago
 
5:08 PM
still looking for some good sql server trivia
 
@swasheck what error will this give?
create table # (col int) ;
 
used that one last time :)
 
@swasheck that's a weird error message
 
@Lamak heh
@ypercube i'm trying to find that select 1except thing
 
select 1except; works.
 
5:16 PM
yoink. got it. search works
@ypercube so it parses as 1e (a number) but is that 1e0 ... so ... 1?
yep
 
5:31 PM
Does anyone object ot my comment on that article I posted?
 
@swasheck something about burritos since Chipotle is a SQL Server shop (at least for BI)
 
Starbucks is also a sql server shop, at least they were
 
@Zane I think that the article kind of does say that?
 
@swasheck also: select 4fun;
 
or select 5%+2
or even select 5%+$2
 
5:43 PM
@AndriyM 1?
@AndriyM does this run?
 
@Lamak Correct
@Lamak Yields 1.00
 
disregard the 4fun
 
*Msg 403, Level 16, State 1, Line 1
Invalid operator for data type. Operator equals modulo, type equals money.*
 
For emacs (and macs) fans:
select 4emacs order by macs ;
 
@Lamak Runs in 2008 R2 and 2012 for me.
 
5:47 PM
or try to trick them with:
What errors will these give?:
select 1word order by word ;
select 4emacs order by macs ;
 
@AndriyM yup, for me too. But I was being an a$$ and tested it on a SQL Server 2000 VM ;-)
 
@Lamak Ha, I thought you tried it in 2014.
I didn't know before that it would work at all.
Floats are (still) not allowed though.
Msg 402, Level 16, State 1, Line 1
The data types int and float are incompatible in the modulo operator.
Which makes sense to me
 
6:27 PM
Got to go kids. Going to let my dog out and then Erin Stellato is giving a speech at my local chapter.
 
WHO LET THE DOGS OUT!?@!?
 
7:11 PM
I have varchar columns in my db where the value is not english ( but hebrew). But How is that happend at first place ? What enabled this to save hebrew letters in a varchar column ?
(Where can I find the setting in SQL server that allowed it ?)
-
-
Foudn it it's the collation. I thought that collation only set the rules for ordering/comparing
but it seems that it also determines the code page. Thanks.
 
7:38 PM
@MikaelEriksson Perfect!
 
7:56 PM
@RoyiNamir Possibly you've also got a corresponding system locale specified in Region and Language (Administrative tab)
 
@AndriyM Wait... so it's not related to collation ?
Or did SQL server - when installed , took this settings and put it as default collation.... ?
 
@RoyiNamir Not really sure about that.
 
Oh ok
 
8:22 PM
@PaulWhite lang-tsql isn't really supported.
Or, if you like, it "works" the same as e.g. lang-lqst, i.e. it falls back to some default highlighting
 
8:33 PM
@AndriyM True. Misremembered the default. Not sure it's worth an edit for the one character. Feel free to do it if you can be bothered.
 
My OCD certainly can, thank you very much
 
8:48 PM
@AndriyM The user did it himself before I got to it.
@AndriyM Seems a better fit for Stack Overflow don't you think? It's been here for 13 hours and only received a very brief "answer" in comments.
 
Paul - can you please shed light ? does the collation of SQL SERVER is set when installing ( auto looking at regional settings) , or is it by a human set when installing ?
 
@PaulWhite To me it's definitely a better fit for SO in the current form. I don't think questions about frameworks like Linq-to-SQL or the one in that question should be asked here but I realise that they can be considered DB tools and therefore formally acceptable, according to our rules.
@RoyiNamir I believe I misunderstood you when you asked that question earlier. Server collation is definitely an option at the time of installation. I mistakenly thought you were asking about how the SQL Server Setup program determines the default value (which you can then change), rather than how a SQL Server instance gets its collation – the latter, as I said, is configurable during setup, the former I don't know.
 
9:09 PM
@RoyiNamir It's an option in setup with a default based on Windows locale. The person doing the installation can change it of course.
 
Thank you . Thank you both.
 
9:48 PM
@AndriyM I added a CW answer. The SO mods didn't object to it coming over to them, if that's what the community decides.
 
10:11 PM
@PaulWhite thnx for the edit
 
@ypercube No worries, I was there dealing with a NAA post.
 
10:32 PM
@Phrancis We tried it
 
11:12 PM
Good morning LA
 
11:30 PM
@AaronBertrand (or anyone else, this is an open discussion) do you still stand by sqlperformance.com/2012/08/t-sql-queries/conditional-order-by if I absolutely can't use SQL Server 2012+ ?
I have to support SQL Server 2008 at a minimum
 
11:41 PM
@PaulWhite busy bee
 

« first day (1687 days earlier)      last day (3195 days later) »