Concatenation in SP''s

  • I posted this in one of the other forums and I thought it should really be in this one....anyway.

    I was told by one of our programmers that doing column concatenation within a stored procedure hinders the performance of the server.

    What I am doing is creating stored procedures and views, within these I concatenate fields such as last_name and first_name like so....

     

    isnull(rtrim(last_name),'') + ', ' + isnull(rtrim(first_name),'')

     

    Is it true that this can cause major performance issues?

     

    Any opinions would be appreciated.

     

    Thx.

  • He is right when he tells that it will cause degredation. However to cause major problems you would have to run these procs a few 1000 times/hours (if the result set is small)... maybe only a few 100 times if the result set is much much larger.

    The best approch in this situation is to send both first and last name in seperate fields and do the concatenation on the client. That you the server does the less work possible.

  • Anything that involves a string function will have a performance hit.

    For example, let us suppose that you want to retrieve all names beginning "Smi".

    Using WHERE PersonName LIKE 'Smi%' will be faster than WHERE LEFT(PersonName,3)='Smi'

    If you could eliminate the RTRIM the performance hit would be less.

    Personally, I would have an update job that periodically RTRIMed those fields as part of a scheduled maintenance routine.

    The concatenation isn't too bad but you don't get owt for nowt

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

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