« first day (3044 days earlier)      last day (2119 days later) » 

06:14
@McNets I did end up implementing that as someone requested it. Please let me know if you find that the change has broken anything.
07:06
@JackDouglas Ok, now I'm a bit busy implementing the new ERP, but I'll take a look ASAP, indeed I'm sure you have done a good job.
Morning
07:26
Morning
Does anyone know if this is possible in SQL Server? I have an XML value: <R><I>A</I><I>B</I><I>C</I></R>. I want to concatenate all I values and return them as a single value: ABC. I know I can do that by shredding the XML and aggregating the results back as a nodeless XML, and then extracting the result using .value('text()[1]', ...). But I'd like to know if it's possible to do all that without shredding, using XPath/XQuery (whatever is the right term) only.
To be more specific, I found this answer:
7
A: Xquery to concatenate

joemfbIn XQuery 3.0, you can use || as a string concatenation operator: return $x || "[" || fn:string-join($y/a, " or ") || "]" In XQuery 1.0, you need to use fn:concat(): return fn:concat($x, fn:concat("[", fn:concat(fn:string-join($y/a, " or "), "]")))

It uses fn:string-join, which didn't work for me (XQuery [value()]: There is no function '{http://www.w3.org/2004/07/xpath-functions}:string-join()')
I guess what I'm asking is whether there's an equivalent to fn:string-join supported by the SQL Server implementation of XQuery
Or maybe just different syntax altogether but with the same result. In my case I don't need to insert delimiters, I just want to concatenate all the values.
 
1 hour later…
08:59
Good morning
09:38
@TomV Oh wow, a for loop, nice! Thanks!
I think I'll post a question. It seemed a quick question when I started asking it but by the end it really grew into a post for the main
@AndriyM Yeah I don't understand why it's adding spaces :(
09:53
@McNets query, I think that's what I was trying to remember. I saw something like that in one of Mikael's answers, or maybe his postings here. Thank you very much, good sir.
@TomV I have no idea either, maybe that's by design, although it's somewhat counter-intuitive. Anyway, here's a variation that doesn't have spaces: dbfiddle.uk/…
Look at us, managing XML problems without Mikael!
10:31
@AndriyM Mikael could probably faster our solutions though
Haha, yes, he probably could
11:04
0
Q: Concatenate all values of the same XML element using XPath/XQuery

Andriy MI have an XML value like this: <R> <I>A</I> <I>B</I> <I>C</I> ... </R> I want to concatenate all I values and return them as a single string: ABC.... Now I know that I can shred the XML, aggregate the results back as a nodeless XML, and apply .values('text()[1]', ...) to the result: ...

@TomV @McNets Please be my guests ^^^
Everyone else is invited too :)
11:26
Aaron seems to be in an edit frenzy.
11:38
I'm working with a really good tester at a customer project the last few weeks. He tests all sorts of expected but more importantly unexpected combinations of user input and then files a bug report "If I do x, then y, then xyz, then z, then x again, then y again, then undo y and redo y, then xyz again abc happens"
Then the analysts have to get into a meeting because nobody has a definitive answer what is supposed to be the outcome if you do all that
I'm looking forward to the ticket where he sacrificed a goat somewhere in the sequence of actions
2
@TomV In my experience, that's a very rare – and extremely valuable – kind.
@TomV Mikael has "stolen" McNets's suggestion but yours hasn't been posted yet. I strongly believe it should be there. Feel free to use the modified version. It's a viable alternative that produces the expected result.
12:20
@AndriyM Added
For your sample XML @McNets code is neater, but you could use the loop in more complex requirements perhaps
@TomV You are right. That's the beauty of having such alternatives. Your solution fits the requirements without being too contrived. And it offers flexibility being more easily adaptable to changes in requirements.
13:05
@AndriyM Oh, your question ended up in HNQ
@TomV It did, slightly more than an hour after being posted. I think it had like 25 views when I first noticed. How they pick them is a total mystery to me.
13:33
95
Q: How do the "arbitrary hotness points" work on the new Stack Exchange home page and in the sidebar on questions?

Maxim ZaslavskyI really like the new Stack Exchange home page, where certain questions from the Stack Exchange Network are presented, along with a hotness rating that is described as "arbitrary" in its tooltip. Such questions also appear randomly on the sidebar on questions across the network, under the heading...

@AndriyM I'm late...
@TomV I did shave some time of with the latest update to my answer.
@AndriyM ^^^
 
2 hours later…
16:14
@MikaelEriksson I don't expect my loop to be very efficient
@TomV Not at all so. SQL Server does magic and comes up with the exact same execution plan as if you don’t use the loop. The other differences makes more of a difference. Don’t use nodes, use the variable twice and loop over R/I/text() and it should be exactly the same as my answer.
 
2 hours later…
18:49
@MikaelEriksson Good to know, because that would defy my expectations. Intuitively, applying nodes before looping would seem to me faster.
@hot2use Not a total mystery now, thanks :)
@McNets On the flip side, Mikael agrees with your suggestion :)
 
3 hours later…
21:58
My first ever nice question. So nice.

« first day (3044 days earlier)      last day (2119 days later) »