January 18, 2009 at 11:11 am
RBarryYoung (1/17/2009)
This being an ORDER BY on the outermost SELECT, it seems that it is guaranteed to be so sorted.
I don't think so it holds in all cases, especially when using case statement, 'cause I do fallen into this many times and only to find it at the last moment.
I would be posting the samples when I am back to work...
--Ramesh
January 18, 2009 at 10:11 pm
... and, still, in an interview, none of the solutions are the correct answer.
Other than a firedrill on this forum, when have any of you actually had to concatenate data in SQL Server in such a fashion in production?
--Jeff Moden
Change is inevitable... Change for the better is not.
January 18, 2009 at 10:45 pm
Jeff Moden (1/18/2009)
... and, still, in an interview, none of the solutions are the correct answer.
Heh, I guess that depends on who's asking. 😛
[font="Times New Roman"]-- RBarryYoung[/font], [font="Times New Roman"] (302)375-0451[/font] blog: MovingSQL.com, Twitter: @RBarryYoung[font="Arial Black"]
Proactive Performance Solutions, Inc. [/font][font="Verdana"] "Performance is our middle name."[/font]
January 19, 2009 at 12:06 am
Jeff Moden (1/18/2009)
Other than a firedrill on this forum, when have any of you actually had to concatenate data in SQL Server in such a fashion in production?
Couple times, but only very small numbers of rows, like using sys.columns to generate an insert script in code. I neither store nor retrieve data concatenated, so have no need to do this on large row sets
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
January 19, 2009 at 3:51 am
I am not a very experienced guy, still I never faced this things in production.
But the thing is, i have faced the same question twice in interview. May b the interviewer used it in their system 😀
January 19, 2009 at 7:31 am
Jeff Moden (1/18/2009)
Other than a firedrill on this forum, when have any of you actually had to concatenate data in SQL Server in such a fashion in production?
For the record, I have had to do it once, about 5 years ago. Not quite like this case (which seems silly and too simple), but the more typical "Group By and concatenate all Z column values in the group".
[font="Times New Roman"]-- RBarryYoung[/font], [font="Times New Roman"] (302)375-0451[/font] blog: MovingSQL.com, Twitter: @RBarryYoung[font="Arial Black"]
Proactive Performance Solutions, Inc. [/font][font="Verdana"] "Performance is our middle name."[/font]
January 19, 2009 at 1:35 pm
I guess that's what I'm getting at, folks. My answer to such a question in an interview would be to first answer the question correctly as many of you have done and then I would tell the interviewer, "But this is a form of denormalization that, with very rare exception, should ever be done in a database unless it's for the creation of some form of dynamic SQL."
--Jeff Moden
Change is inevitable... Change for the better is not.
January 19, 2009 at 3:14 pm
Jeff Moden (1/19/2009)
I guess that's what I'm getting at, folks. My answer to such a question in an interview would be to first answer the question correctly as many of you have done and then I would tell the interviewer, "But this is a form of denormalization that, with very rare exception, should ever be done in a database unless it's for the creation of some form of dynamic SQL."
Heh. Wow, you're right of course, I do use this technique for Dynamic SQL generation all the time. I can't believe that I forgot that, complete brain freeze. :w00t:
[font="Times New Roman"]-- RBarryYoung[/font], [font="Times New Roman"] (302)375-0451[/font] blog: MovingSQL.com, Twitter: @RBarryYoung[font="Arial Black"]
Proactive Performance Solutions, Inc. [/font][font="Verdana"] "Performance is our middle name."[/font]
Viewing 8 posts - 16 through 22 (of 22 total)
You must be logged in to reply to this topic. Login to reply