Home Forums SQL Server 2008 T-SQL (SS2K8) Convert values of mulitiple rows into single column with no duplicate entries RE: Convert values of mulitiple rows into single column with no duplicate entries

  • CELKO (11/18/2012)


    I went through the forum and found out a way of concatenating row values into column using stuff, but can't figure out how to remove duplicates and only display them once.

    Why do you wish to destroy and violate the principle of tiered architectures? Why do you want to write proprietary, unmaintainable code?

    I cannot see how concatenating distinct values from rows into single (some-character separated) value is destroying and violating principals of tiered architecture. More than that, when it became available to achieve easily in T-SQL, it was real help in many solutions (client applications and especially - reporting ones).

    Also, there is absolutely nothing wrong with using proprietary functionality of MS T-SQL. It would be stupid to suggest not to use features of T-SQL which quite often makes it stand out from another RDBMS solutions. Would you ask Oracle developers not to use Oracle specific features/libraries?

    Actually, if you so against "proprietary" coding, what do you think in coding practices generally?

    No C#, VB.NET as it's MS proprietary, no Java as it's IBM one... Looks like every language (eg. assembler), in certain extend is a proprietary...

    Why do you think that there is a real need of porting every single solution from one language/system base to another? How often does it happen in real life? Is it use of proprietary features, is the main issue when you port an application?

    My answers to above three questions would be:

    1. No much need!

    2. Not very often, definitely less often then replacing system completely.

    3. No, it's clearly not. Replacing ISNULL with COALESCE, for example is nothing in comparison with issues related with use of new drivers, OS architecture, security and many other...

    And about "unmaintainable code". The technique used by OP is well known among T-SQL professionals and it's one of the best and used methods to achieve what OP needs. How does it compromise maintainability? If this block of code is appropriately commented and nicely formatted (for ease of read), it will not effect code maintainability in any manner.

    _____________________________________________
    "The only true wisdom is in knowing you know nothing"
    "O skol'ko nam otkrytiy chudnyh prevnosit microsofta duh!":-D
    (So many miracle inventions provided by MS to us...)

    How to post your question to get the best and quick help[/url]