May 4, 2016 at 8:28 am
Do this so many times I didn't catch that the STUFF function was missing. Got it right without it there.
May 4, 2016 at 8:35 am
Lynn Pettis (5/4/2016)
Do this so many times I didn't catch that the STUFF function was missing. Got it right without it there.
Right there with you. The technique is a good one.
May 4, 2016 at 8:37 am
Could say this is a "May the force be with you" type question.
May 4, 2016 at 8:52 am
I can't see STUFF() in here and I'm not entirely sure where it would be used but I can make a decent guess about what the purpose is. I'd like to see the fixed code so I can make use of it.
May 4, 2016 at 8:56 am
krachynski (5/4/2016)
I can't see STUFF() in here and I'm not entirely sure where it would be used but I can make a decent guess about what the purpose is. I'd like to see the fixed code so I can make use of it.
WITH CTE AS
(
SELECT DISTINCT
AccountNumber
FROM #TestData
)
SELECT AccountNumber,
CommaList = STUFF((
SELECT ',' + Value
FROM #TestData
WHERE AccountNumber = CTE.AccountNumber
ORDER BY Value
FOR XML PATH(''),
TYPE).value('.','varchar(max)'),1,1,'')
FROM CTE
ORDER BY AccountNumber;
May 4, 2016 at 9:11 am
I'd no more ask this person to administer my database than I'd ask Donald Trump to run my country.
May 4, 2016 at 9:14 am
It came from Wayne Sheffield's SQL Spackle article on string concatenation. The article is at http://www.sqlservercentral.com/articles/comma+separated+list/71700/. It's a great technique.
May 4, 2016 at 9:16 am
Ed Wagner (5/4/2016)
It came from Wayne Sheffield's SQL Spackle article on string concatenation. The article is at http://www.sqlservercentral.com/articles/comma+separated+list/71700/. It's a great technique.
It's broken so no, it's not great.
May 4, 2016 at 9:19 am
edwardwill (5/4/2016)
I'd no more ask this person to administer my database than I'd ask Donald Trump to run my country.
Wow, you have your own country? Must be awesome!
May 4, 2016 at 9:19 am
edwardwill (5/4/2016)
Ed Wagner (5/4/2016)
It came from Wayne Sheffield's SQL Spackle article on string concatenation. The article is at http://www.sqlservercentral.com/articles/comma+separated+list/71700/. It's a great technique.It's broken so no, it's not great.
What's broken?
May 4, 2016 at 9:20 am
Oh I see, the full query is linked after you answer the QotD.
May 4, 2016 at 9:22 am
edwardwill (5/4/2016)
Ed Wagner (5/4/2016)
It came from Wayne Sheffield's SQL Spackle article on string concatenation. The article is at http://www.sqlservercentral.com/articles/comma+separated+list/71700/. It's a great technique.It's broken so no, it's not great.
The link works fine for me, so I don't see why you're having trouble with it. Try copying and pasting the URL into your browser.
If that doesn't work for you, click Authors on the left menu, then click Wayne's name. You'll find this article about half-way down the list.
It is a nice, short article and the technique works very well.
May 4, 2016 at 9:24 am
Ed Wagner (5/4/2016)
edwardwill (5/4/2016)
Ed Wagner (5/4/2016)
It came from Wayne Sheffield's SQL Spackle article on string concatenation. The article is at http://www.sqlservercentral.com/articles/comma+separated+list/71700/. It's a great technique.It's broken so no, it's not great.
The link works fine for me, so I don't see why you're having trouble with it. Try copying and pasting the URL into your browser.
If that doesn't work for you, click Authors on the left menu, then click Wayne's name. You'll find this article about half-way down the list.
It is a nice, short article and the technique works very well.
No, I meant the code that we were supposed to be parsing is broken (it was missing STUFF): I already know about, and use, the technique.
May 4, 2016 at 9:26 am
Lynn Pettis (5/4/2016)
edwardwill (5/4/2016)
I'd no more ask this person to administer my database than I'd ask Donald Trump to run my country.Wow, you have your own country? Must be awesome!
Seriously?
May 4, 2016 at 9:26 am
edwardwill (5/4/2016)
Ed Wagner (5/4/2016)
edwardwill (5/4/2016)
Ed Wagner (5/4/2016)
It came from Wayne Sheffield's SQL Spackle article on string concatenation. The article is at http://www.sqlservercentral.com/articles/comma+separated+list/71700/. It's a great technique.It's broken so no, it's not great.
The link works fine for me, so I don't see why you're having trouble with it. Try copying and pasting the URL into your browser.
If that doesn't work for you, click Authors on the left menu, then click Wayne's name. You'll find this article about half-way down the list.
It is a nice, short article and the technique works very well.
No, I meant the code that we were supposed to be parsing is broken (it was missing STUFF): I already know about, and use, the technique.
Everyone has noted that the STUFF() is missing. Interesting thing is no one demanding their points back.
Viewing 15 posts - 16 through 30 (of 54 total)
You must be logged in to reply to this topic. Login to reply