|
I may be chasing down something that just isn't possible with SQL (T-SQL, to be specific) but I'm trying to disentangle records with a '&' delimited between two first names, and then create two rows from that process, one for each person. It's...almost working, but I'm not playing horseshoes so I'm not happy with almost. My sample data is as follows: code:
SQL code:
There are more cleanup steps I have planned but I'm also starting to think at this point that maybe I want to route my data through some python code to manipulate it instead? Ultimately my goal is to have a result table that has an entry code:
Am I just barking up the wrong tree with SQL for this kind of thing?
|
# ¿ Jan 25, 2023 17:52 |
|
|
# ¿ May 21, 2024 06:42 |
|
Thanks! Most of the cleanup I need to apply is covered by the replace and trim operators so that's one less checkbox for me! Is there a particular functional reason for using a table variable rather than SELECTing right from my already-populated Contacts table?
|
# ¿ Jan 25, 2023 19:00 |
|
Macichne Leainig posted:I asked it to give me a null cipher once, and I poo poo you not, it basically told me "the first letter of each word from the sentence 'the dog ran away' spells a message. for example, 'the,' dog', and 'ran' spells "HELP" " "If you can't dazzle them with brilliance, baffle them with bullshit," is surprisingly human
|
# ¿ Feb 18, 2023 01:37 |
|
kumba posted:That was my first guess, but it does not! i can select distinct bs.Month for the timeframe and there's nothing weird at all - just a list of 6 character values that I would expect to see! Does including a code:
is the schema using something weird like SMALLDATETIME?
|
# ¿ Aug 16, 2023 16:16 |
|
I will occasionally tap into ChatGPT when I need my statements to bridge the gap between "clever" and "fancy", and did so this morning when working with some data exported from salesforce (my goal was to take each Account with a type of 'Household' from the Accounts file and populate, in-line, the primary household member (indicated in the one2oneContact field as per usual SF) and all associated members of the household identified by the [AccountId] in the Contacts file - the insert script for this particular item in our database is built around the expectation that we are getting data in the form of [HouseholdID][Member1][Member2][Member3] and so on - suffice to say it needs some serious reworking but that's neither here nor there). Anyway, chatGPT gave me a fine output. It might not be the most efficient way to do it, but it gives me the results I want. I've got to export the results to excel and do a text to columns then re-import it, but it's still way less annoying than it could be. My question, ultimately, is with ChatGPT's followup 'notes' or whatever. quote:In this query, the ContactConcatenation CTE uses the STUFF and FOR XML PATH('') technique to concatenate the secondary contact IDs into a single column. What exactly is the "STUFF and FOR XML PATH('') technique" and what is it doing? I can provide the full output here, but the relevant code bit is this: code:
|
# ¿ Aug 21, 2023 21:45 |
|
And there's the problem with ChatGPT: I can use STRING_AGG lmfao
|
# ¿ Aug 21, 2023 23:47 |
|
Yeah I could have really improved my prompt there in retrospect.
|
# ¿ Aug 22, 2023 00:07 |
|
I'm far from a seasoned DBA but so far as working in a client onboarding/ETL capacity goes I sure appreciate it when id columns are named thing_id because it makes mapping data from legacy systems more intuitive (ask me about staring into the horrors of a raiser's edge backup file)
|
# ¿ Oct 27, 2023 00:58 |
|
Just-In-Timeberlake posted:lmao the database I inherited would give you all nightmares [laughs in democratic party fundraising and engagement database]
|
# ¿ Oct 27, 2023 01:15 |
|
shame on an IGA posted:oh poo poo I think I'm one of your users was. have a backup plan ready.
|
# ¿ Oct 27, 2023 02:06 |
|
I would blow Dane Cook posted:With halloween just been and gone, what's your spookiest database experience? I mentioned NGP VAN, right? e: "a client needs the disclosure report updated for this batch of thousands of donations." "ok, where do those values live?" "no one knows. make the change in the front-end and see what updates." "I can't change the front end. The batch is closed." "Yeah." Lib and let die fucked around with this message at 14:28 on Nov 6, 2023 |
# ¿ Nov 6, 2023 14:19 |
|
Heh, mini-Vinnie
|
# ¿ Nov 11, 2023 17:01 |
|
GigaPeon posted:Also there’s so much AI poo poo. How are people just cool with hooking up their environments to the internet and sending it to a third party? Look, we have to take risks, it's part of doing business. At least, that's what Scott Brighton, CEO of Bonterera, parent company of NGP VAN, the Democrat Party's purpose-built voter engagement and fundraising platform has to say about leveraging AI. God I can't wait 'til '24 kicks into high gear and the bottom falls out.
|
# ¿ Nov 17, 2023 13:48 |
|
Commas before, you filthy animals
|
# ¿ Nov 21, 2023 19:15 |
|
|
# ¿ May 21, 2024 06:42 |
|
SQL Prompt is really handy for refactoring but I don't know that I'd pay redgate prices just for that. We were always told that its use was non-optional because of stuff like detecting UPDATE or DELETE statements without WHERE clauses and less about making our code pretty.
|
# ¿ Nov 21, 2023 20:24 |