February 18, 2010 at 9:31 pm
Comments posted to this topic are about the item FOR XML PATH
[font="Arial Narrow"]bc[/font]
February 18, 2010 at 10:34 pm
This was removed by the editor as SPAM
February 19, 2010 at 12:27 am
Nice question.
Jason...AKA CirqueDeSQLeil
_______________________________________________
I have given a name to my pain...MCM SQL Server, MVP
SQL RNNR
Posting Performance Based Questions - Gail Shaw[/url]
Learn Extended Events
February 19, 2010 at 12:31 am
thanks for the question.. good one! 🙂
February 19, 2010 at 1:25 am
Not sure if it was a browser issue but couldn't copy the script to paste into Query Analyser, anyone else have that problem?
Glen Parker 🙂
February 19, 2010 at 2:30 am
Great question made me remember to re - read the question a couple of times before shouting "Errggghhhh!!!"
February 19, 2010 at 3:02 am
GlenParker (2/19/2010)
Not sure if it was a browser issue but couldn't copy the script to paste into Query Analyser, anyone else have that problem?
It's an image rather than text, presumably to prevent people just copying and pasting into SSMS to find the answer - ie to make us think!
I got it right, but only because I was expecting an error that wasn't in the list*, so assumed it must be valid after all 🙂
(* I thought it would object to Colors being in the select list but not the group by)
February 19, 2010 at 4:28 am
I liked it like that. It was nice to know that short of copying it letter for letter or using OCR to read the text back, everyone answering should have been answering based on how they understood it rather than because they simply ran the code themselves and put the correct answer
Thanks
Paul
February 19, 2010 at 4:56 am
Good question..I was confused with ans. 1 & 3, went for a toss and lost it. I give too many wrong answeres now a days..Need to be thorough with wot I learn...Questions like this remind me of that fact.
Thanks.
February 19, 2010 at 7:23 am
I like the question but more importantly I enjoyed the fact that it was an image. Forcing users to think it out.
I was a little thrown off because I thought it would come back with 4 rows. So I assumed the answer meant to say 4 rows of data returned with row 4 = 'black&white,gray'
Great question though. Here comes the debate on why some user couldn't copy the question and then answer it... 😀
February 19, 2010 at 7:54 am
Glad most folks liked it. Here is the actual code (you'll have to remove the *'s around amp to make it work):
WITH cteData (ID, Colors) AS
(SELECT1, 'Blue'
UNION
SELECT2, 'Red'
UNION
SELECT3, 'Yellow'
UNION
SELECT4, 'Gray'
UNION
SELECT1, 'Purple'
UNION
SELECT2, 'Orange'
UNION
SELECT3, 'Green'
UNION
SELECT4, 'Black & White')
SELECTREPLACE(STUFF((SELECT ', ' + d.Colors
FROM [cteData] d
WHERE c.[ID] = d.[ID]
ORDER BY [d].[Colors]
FOR XML PATH('')),1,1,''), '&*amp*;', '&') [ColorList]
FROM[cteData] c
GROUP BY c.[ID]
ORDER BY c.[ID]
[font="Arial Narrow"]bc[/font]
February 19, 2010 at 8:25 am
Good question. The best part was image instead of text. By looking at the question I thought
/* The replace function requires 3 argument(s) */
would be the answer but while writing the same code in SSMS I realized it would return four rows and option 1 should be the answer.
SQL DBA.
February 19, 2010 at 9:39 am
Good question. (Maybe because I got it right?). No, actually it was a good question that made me read slowly and think it through.
February 19, 2010 at 10:29 am
paul.goldstraw (2/19/2010)
I liked it like that. It was nice to know that short of copying it letter for letter or using OCR to read the text back, everyone answering should have been answering based on how they understood it rather than because they simply ran the code themselves and put the correct answerThanks
Paul
I too liked that the question was done this way. The answers were well formulated and if read - I think they could help deduce the answer quickly. One really needed to read the script and interpret it.
Jason...AKA CirqueDeSQLeil
_______________________________________________
I have given a name to my pain...MCM SQL Server, MVP
SQL RNNR
Posting Performance Based Questions - Gail Shaw[/url]
Learn Extended Events
February 19, 2010 at 9:47 pm
Good One.
I also used STUFF and FOR XML to solve a problem at my workplace, but was surprised to see &
Viewing 15 posts - 1 through 15 (of 24 total)
You must be logged in to reply to this topic. Login to reply