• sqldba20 (2/20/2014)


    It is only for display purpose in reporting because the user doesn't want to see 4 rows for each record if there are 4 email ids for that AID.

    You may find it more efficient to perform this relatively simple operation in the code which generates the #temp table, rather than updating the temp table afterwards. If you're not sure how to do this, post the code and we'll help.

    “Write the query the simplest way. If through testing it becomes clear that the performance is inadequate, consider alternative query forms.” - Gail Shaw

    For fast, accurate and documented assistance in answering your questions, please read this article.
    Understanding and using APPLY, (I) and (II) Paul White
    Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden