Concatenation within Stored Procedures

  • 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.

  • I already answered this question under your other post.

  • hi,

    I have never heard that concatinating in and of itself causes any problems. maybe if you were using a cursor to achieve it. 

    I suppose in the strictest sense if you do anything to the data it will cause things to slow down but common sense would tell you that it is hard to justify that position.

    I suspect that your programmer friend has several caveats that are in place behind that statement like "in foxpro v2" or "once when reading from a dos file"

    go ahead and canct if you want to and tell the programmer to let you do what databases do - manipulate data.

    just some comments

     

    Tal McMahon

     

  • Sure things, this can hurt performance. Just put this

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

    in the WHERE clause of a query that runs against a table with millions of rows. I'll bet you get a nice table scan.

    Apart from this, I think this is merely a presentational issue which is best handled at the client.

    --
    Frank Kalis
    Microsoft SQL Server MVP
    Webmaster: http://www.insidesql.org/blogs
    My blog: http://www.insidesql.org/blogs/frankkalis/[/url]

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

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