Combine multiple rows into single output

  • Mohit Nayyar

    Ten Centuries

    Points: 1008

    Comments posted to this topic are about the item Combine multiple rows into single output

    Thanks
    Mohit Nayyar
    http://mohitnayyar.blogspot.com/
    "If I am destined to fail, then I do have a purpose in my life, To fail my destiny"

  • kevin.l.williams

    SSCarpal Tunnel

    Points: 4898

    Thanks Mohit. This sure saved me some time!

  • Angarika

    Grasshopper

    Points: 17

    Hi,

    I am facing one performance issue.This is the scenario.

    For eg., EmpId,EmpName,DeptId,DeptName,Sal are there.Except sal all the remaining columns values are same(I mean having same data).

    Assume,here 4 rows are there in that table.

    so I wrote a select query to get the data like 1,xx,1,yy,50,500,5000,1000

    here 50,500,5000,1000... are the sal column values.

    I wrote a function to get the sal values as comma separated ones if the remaining column values are same.But for Huge no' of records (assume for 25000 records), the performance is very bad.:crying:

    So need a inbuilt query / any other solution for this problem.

  • jinal-726623

    Old Hand

    Points: 300

    For same purpose we can use cussor too.

    Can you specify which idea is better and why ?

    Cursor Or UDF.

  • SQLSandwiches

    SSCrazy

    Points: 2141

    Ran into the same issue here. This function causes my query to literally be 15 times slower. Going from under 1 second to over 15.

    Haven't found a work around yet.

  • SQLSandwiches

    SSCrazy

    Points: 2141

    Actually I fixed this problem. I added an index on the table that I used in the function. This sped things right back up.

    Have you tried adding some indexes?

Viewing 6 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic. Login to reply